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). "