- Add backend stale process monitoring API (/api/stale-processes) - Add users management route - Add frontend landing page and stale process monitor UI on /scraper-tools - Move old development scripts to backend/archive/ - Update frontend build with new features 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { pool } from './src/db/migrate.js';
|
|
|
|
async function main() {
|
|
// Check job status
|
|
const statusResult = await pool.query(`
|
|
SELECT status, COUNT(*) as count
|
|
FROM brand_scrape_jobs
|
|
WHERE dispensary_id = 112
|
|
GROUP BY status
|
|
ORDER BY status
|
|
`);
|
|
|
|
console.log('\nJob Status Distribution:');
|
|
statusResult.rows.forEach(row => {
|
|
console.log(` ${row.status}: ${row.count}`);
|
|
});
|
|
|
|
// Reset one completed job to pending
|
|
const resetResult = await pool.query(`
|
|
UPDATE brand_scrape_jobs
|
|
SET status = 'pending',
|
|
worker_id = NULL,
|
|
started_at = NULL,
|
|
completed_at = NULL,
|
|
products_found = NULL,
|
|
products_saved = NULL,
|
|
updated_at = NOW()
|
|
WHERE dispensary_id = 112
|
|
AND status = 'completed'
|
|
AND brand_slug = 'select'
|
|
RETURNING id, brand_name, status
|
|
`);
|
|
|
|
if (resetResult.rows.length > 0) {
|
|
console.log(`\nReset job: ${resetResult.rows[0].brand_name} (ID: ${resetResult.rows[0].id})`);
|
|
} else {
|
|
console.log('\nNo job reset (Select brand not found in completed jobs)');
|
|
}
|
|
|
|
await pool.end();
|
|
}
|
|
|
|
main().catch(console.error);
|