From 776d831fb82bdfca8e6e772fbdce0bfbfee3363e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sat, 27 Jun 2026 13:18:55 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20PG-=D0=BE=D1=87=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D1=8C=20=E2=80=94=20classify=5Fstatus=3D'processing'=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20crash=20recovery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/db/documents.py | 10 +++++++++- deploy/services/classify.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/deploy/db/documents.py b/deploy/db/documents.py index e6d5d33..76f9e64 100644 --- a/deploy/db/documents.py +++ b/deploy/db/documents.py @@ -70,13 +70,21 @@ def list_pending(batch_id): def reset_classify_status(batch_id): - """Сбросить classify_status на 'pending' для всех документов батча.""" + """Сбросить classify_status на 'pending' для всех документов батча (включая 'processing' — crash recovery).""" return execute( "UPDATE documents SET classify_status='pending', error_message=NULL WHERE batch_id=%s", (batch_id,), ) +def set_classify_processing(doc_id): + """Mark document as being processed (for crash recovery).""" + return execute( + "UPDATE documents SET classify_status='processing' WHERE id=%s", + (doc_id,), + ) + + def list_by_batch(batch_id): """All documents in a batch with classification fields.""" return query( diff --git a/deploy/services/classify.py b/deploy/services/classify.py index e85c2a7..137e6ee 100644 --- a/deploy/services/classify.py +++ b/deploy/services/classify.py @@ -116,6 +116,7 @@ def classify_batch(batch_id): return True # Stage 3: LLM classification (only for remaining) + db_docs.set_classify_processing(doc["id"]) # crash recovery marker result, raw, needed_fix = _call_llm_classify(text) json_total += 1 if needed_fix: