File size: 590 Bytes
20b15f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from fastapi import APIRouter, HTTPException
from app.modules.search.jobs import get_job
from app.modules.search.schemas import SearchStatusResponse
router = APIRouter(prefix="/search", tags=["search"])
@router.get("/status/{job_id}", response_model=SearchStatusResponse)
def search_status(job_id: str):
"""Poll this until status is 'done' (or 'error'). On 'done',
clustered_papers is the final payload the UI renders."""
job = get_job(job_id)
if job is None:
raise HTTPException(status_code=404, detail="Unknown job_id.")
return SearchStatusResponse(**job)
|