From e939c320cc875efade0a52596d3652b534678666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Wed, 24 Jun 2026 15:17:45 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.174:=20classify=5Fbatch=20=D1=81=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D1=83=D1=81=20=D0=BD=D0=B0=20pending=20=E2=80=94?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BB=D0=B5=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/db/documents.py | 8 ++++++++ deploy/services/classify.py | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/deploy/db/documents.py b/deploy/db/documents.py index 5068932..cf2ccdb 100644 --- a/deploy/db/documents.py +++ b/deploy/db/documents.py @@ -61,6 +61,14 @@ def list_pending(batch_id): ) +def reset_classify_status(batch_id): + """Сбросить classify_status на 'pending' для всех документов батча.""" + return execute( + "UPDATE documents SET classify_status='pending', error_message=NULL WHERE batch_id=%s AND status='parsed'", + (batch_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 2d0d38c..7064fa2 100644 --- a/deploy/services/classify.py +++ b/deploy/services/classify.py @@ -55,11 +55,13 @@ def _call_llm_classify(header_text): def classify_batch(batch_id): """ - Классифицировать все pending-документы в batch. - Вызывается из эндпоинта POST /api/classify-batch. + Классифицировать все документы в batch. + Сбрасывает статус на 'pending' для всех перед началом. Параллельно (ThreadPoolExecutor) обрабатывает до MAX_WORKERS документов. Возвращает {ok, total, done, failed}. """ + # Сбросить статус — allow re-classify after file changes + db_docs.reset_classify_status(batch_id) pending = db_docs.list_pending(batch_id) if not pending: return {"ok": False, "error": "no pending documents"}