feat: Add POST /api/tasks/fix-null-methods endpoint
Updates null method tasks to 'http' for proper worker qualification 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -891,6 +891,35 @@ router.post('/retry-failed', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/tasks/fix-null-methods
|
||||||
|
* Update tasks with method=null to method='http'
|
||||||
|
* Ensures only HTTP-preflight workers can claim crawl tasks
|
||||||
|
*/
|
||||||
|
router.post('/fix-null-methods', async (_req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
const { rows } = await pool.query(`
|
||||||
|
UPDATE worker_tasks
|
||||||
|
SET method = 'http', updated_at = NOW()
|
||||||
|
WHERE method IS NULL
|
||||||
|
AND role IN ('product_discovery', 'product_refresh', 'entry_point_discovery', 'store_discovery', 'payload_fetch')
|
||||||
|
AND status IN ('pending', 'failed')
|
||||||
|
RETURNING id, role, status
|
||||||
|
`);
|
||||||
|
|
||||||
|
console.log(`[Tasks] Fixed ${rows.length} tasks with null method → http`);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
tasks_fixed: rows.length,
|
||||||
|
tasks: rows.slice(0, 20),
|
||||||
|
});
|
||||||
|
} catch (error: unknown) {
|
||||||
|
console.error('Error fixing null methods:', error);
|
||||||
|
res.status(500).json({ error: 'Failed to fix null methods' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/tasks/role/:role/last-completion
|
* GET /api/tasks/role/:role/last-completion
|
||||||
* Get the last completion time for a role
|
* Get the last completion time for a role
|
||||||
|
|||||||
Reference in New Issue
Block a user