From ed474c521afc29a578c591a6d00bbca56d501a9a Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Fri, 10 Jul 2026 22:09:02 +0000 Subject: [PATCH] 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. --- services/extractor/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/extractor/main.py b/services/extractor/main.py index 8fabe85..6288793 100644 --- a/services/extractor/main.py +++ b/services/extractor/main.py @@ -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). "