fix: bugs-01
This commit is contained in:
@@ -57,10 +57,14 @@ async def upload_images(
|
||||
await db.flush()
|
||||
|
||||
# trigger OCR tasks in-process background (non-blocking for API response)
|
||||
from app.workers.ocr_tasks import process_image_ocr_async
|
||||
for img in results:
|
||||
if img.ocr_status.value == "pending":
|
||||
asyncio.create_task(process_image_ocr_async(str(img.id)))
|
||||
from app.workers.ocr_tasks import process_images_ocr_batch_async
|
||||
pending_ids = [str(img.id) for img in results if img.ocr_status.value == "pending"]
|
||||
if pending_ids:
|
||||
asyncio.create_task(
|
||||
process_images_ocr_batch_async(
|
||||
pending_ids, settings.OCR_PARALLELISM
|
||||
)
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
@@ -169,12 +173,16 @@ async def start_case_ocr(
|
||||
else:
|
||||
images = await repo.list_for_ocr(case_id, include_done=include_done)
|
||||
|
||||
from app.workers.ocr_tasks import process_image_ocr_async
|
||||
from app.workers.ocr_tasks import process_images_ocr_batch_async
|
||||
|
||||
submitted = 0
|
||||
for img in images:
|
||||
asyncio.create_task(process_image_ocr_async(str(img.id)))
|
||||
submitted += 1
|
||||
image_ids_to_run = [str(img.id) for img in images]
|
||||
submitted = len(image_ids_to_run)
|
||||
if image_ids_to_run:
|
||||
asyncio.create_task(
|
||||
process_images_ocr_batch_async(
|
||||
image_ids_to_run, settings.OCR_PARALLELISM
|
||||
)
|
||||
)
|
||||
|
||||
return {
|
||||
"caseId": str(case_id),
|
||||
|
||||
Reference in New Issue
Block a user