fix(precedent-library): per-record extraction must drain the queue too
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m36s

reextract_metadata / reextract_halachot extract & apply but never cleared
metadata_extraction_requested_at / halacha_extraction_requested_at —
only the bulk worker (process_pending_extractions) did. Result: clicking
"חלץ מטא-דאטה" on the edit sheet (or calling precedent_extract_metadata
directly) left the row stuck in the queue forever, with the UI badge
showing "ממתין לחילוץ" even after extraction succeeded.

Mirror the worker's behaviour: on success ('completed' / 'no_changes' /
'no_halachot'), call db.clear_extraction_request to drain the queue.

Coolify deploy required for the FastAPI container; local MCP server
needs a process restart for the change to take effect (long-running).
This commit is contained in:
2026-05-07 07:08:31 +00:00
parent 36b78ea404
commit fff2d1c859

View File

@@ -265,6 +265,11 @@ async def reextract_halachot(
await progress("extracting_halachot", 50, "מחלץ הלכות מחדש") await progress("extracting_halachot", 50, "מחלץ הלכות מחדש")
result = await halacha_extractor.extract(case_law_id) result = await halacha_extractor.extract(case_law_id)
# Clear the queue timestamp on completion so the UI badge / worker queue
# don't keep showing this row. The queue worker (process_pending_extractions)
# already does this; mirror it here so per-record extraction drains too.
if result.get("status") in ("completed", "no_halachot"):
await db.clear_extraction_request(case_law_id, kind="halacha")
await progress( await progress(
"completed", "completed",
100, 100,
@@ -411,6 +416,10 @@ async def reextract_metadata(
await progress("extracting_metadata", 40, "מחלץ מטא-דאטה (תקציר, תגיות)") await progress("extracting_metadata", 40, "מחלץ מטא-דאטה (תקציר, תגיות)")
result = await precedent_metadata_extractor.extract_and_apply(case_law_id) result = await precedent_metadata_extractor.extract_and_apply(case_law_id)
# Clear the queue timestamp so the UI / worker stop showing this row.
# See note in reextract_halachot.
if result.get("status") in ("completed", "no_changes"):
await db.clear_extraction_request(case_law_id, kind="metadata")
fields = result.get("fields") or [] fields = result.get("fields") or []
msg = ( msg = (
f"מולאו {len(fields)} שדות: {', '.join(fields)}" f"מולאו {len(fields)} שדות: {', '.join(fields)}"