fix: recovery sweep skips docs that already have global_events — prevents re-enqueue loop
This commit is contained in:
@@ -522,6 +522,9 @@ async def recover_stale_documents(pool: asyncpg.Pool, rds: aioredis.Redis) -> in
|
|||||||
LEFT JOIN document_company_mentions dcm ON d.id = dcm.document_id
|
LEFT JOIN document_company_mentions dcm ON d.id = dcm.document_id
|
||||||
WHERE d.status = 'parsed'
|
WHERE d.status = 'parsed'
|
||||||
AND d.updated_at < NOW() - INTERVAL '1 minute' * $1
|
AND d.updated_at < NOW() - INTERVAL '1 minute' * $1
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM global_events ge WHERE ge.source_document_id = d.id
|
||||||
|
)
|
||||||
ORDER BY d.created_at ASC
|
ORDER BY d.created_at ASC
|
||||||
LIMIT 100""",
|
LIMIT 100""",
|
||||||
STALE_PARSED_THRESHOLD_MINUTES,
|
STALE_PARSED_THRESHOLD_MINUTES,
|
||||||
|
|||||||
Reference in New Issue
Block a user