Group search results by owner; auto-resume stuck pending documents
This commit is contained in:
@@ -233,6 +233,27 @@ async def retry_all_errors():
|
||||
return JSONResponse({"ok": True, "retried": len(rows)})
|
||||
|
||||
|
||||
@router.post("/documents/resume-pending")
|
||||
async def resume_pending():
|
||||
"""Re-fire background extraction for any docs stuck in 'pending'.
|
||||
Useful when a previous server restart killed in-flight extraction tasks."""
|
||||
import asyncio
|
||||
from services.extractor import get_default_provider
|
||||
from routers.upload import _extract_and_save
|
||||
|
||||
default_provider = get_default_provider()
|
||||
with get_db() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT id, image_path, provider FROM documents WHERE status='pending'"
|
||||
).fetchall()
|
||||
|
||||
for row in rows:
|
||||
provider = row["provider"] or default_provider
|
||||
asyncio.create_task(_extract_and_save(row["id"], row["image_path"], provider))
|
||||
|
||||
return JSONResponse({"ok": True, "resumed": len(rows)})
|
||||
|
||||
|
||||
@router.post("/documents/scan-duplicates")
|
||||
async def scan_duplicates():
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user