v1.0.174: classify_batch сбрасывает статус на pending — работает после удаления файлов
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user