fix: update document status after macro classification

_process_macro_classification never updated document status, leaving
macro_event docs stuck in parsed forever. Now marks them extracted on
success or extraction_failed on error.
This commit is contained in:
Celes Renata
2026-07-10 22:09:02 +00:00
parent e8e348d478
commit ed474c521a
+15
View File
@@ -308,9 +308,20 @@ async def _process_macro_classification(
len(enqueued_tickers), event.event_id,
)
# Update document status to 'extracted' (macro classification is the extraction for these docs)
await pool.execute(
"UPDATE documents SET status = 'extracted', updated_at = NOW() WHERE id = $1::uuid",
document_id,
)
except ValueError as e:
_macro_consecutive_failures += 1
logger.error("Macro event classification failed for doc %s: %s", document_id, e)
# Mark as extraction_failed so it can be retried
await pool.execute(
"UPDATE documents SET status = 'extraction_failed', updated_at = NOW() WHERE id = $1::uuid",
document_id,
)
if _macro_consecutive_failures >= _MACRO_FAILURE_ALERT_THRESHOLD:
logger.critical(
"ALERT: Sustained macro classification failures (%d consecutive). "
@@ -320,6 +331,10 @@ async def _process_macro_classification(
except Exception:
_macro_consecutive_failures += 1
logger.exception("Unexpected error classifying macro event for doc %s", document_id)
await pool.execute(
"UPDATE documents SET status = 'extraction_failed', updated_at = NOW() WHERE id = $1::uuid",
document_id,
)
if _macro_consecutive_failures >= _MACRO_FAILURE_ALERT_THRESHOLD:
logger.critical(
"ALERT: Sustained macro classification failures (%d consecutive). "