-
Couldn't load subscription status.
- Fork 0
Feat: Add endpoint to retrieve final report data #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a service function to retrieve report data from the in-memory store and a new GET /reports/{report_id}/data endpoint that returns completed data, processing (202), failed (409), or not-found (404) results; updates import paths in main and adds async tests for the new endpoint. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API as GET /api/v1/reports/{id}/data
participant Service as get_report_data(report_id)
participant Store as In-Memory Store
Client->>API: Request report data
API->>Service: get_report_data(report_id)
Service->>Store: lookup(report_id)
alt found & status == "completed"
Store-->>Service: report with agent_results
Service-->>API: {report_id, data}
API-->>Client: 200 OK (body: data)
else found & status == "processing"
Store-->>Service: report with status "processing"
Service-->>API: {report_id, status}
API-->>Client: 202 Accepted (JSONResponse: still processing)
else found & status == "failed"
Store-->>Service: report with status "failed"
Service-->>API: {report_id, status}
API-->>Client: 409 Conflict (JSONResponse: failed)
else not found
Store-->>Service: None
Service-->>API: None
API-->>Client: 404 Not Found (HTTPException)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (1)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
backend/tests/test_routes.py (2)
22-34: Avoid brittle full-body equality for 202; assert key fieldsReduce coupling to response shape while still validating semantics.
Apply:
- assert response.status_code == 202 - assert response.json() == {"report_id": report_id, "message": "Report is still processing.", "detail": "Report is still processing."} # Added detail to match the actual response + assert response.status_code == 202 + body = response.json() + assert body["report_id"] == report_id + assert body["detail"] == "Report is still processing." + assert body.get("message") == "Report is still processing."
45-51: Reduce flakiness: poll for completion instead of fixed sleepPolling with a timeout is more reliable than
sleep(2).Apply:
- # Wait for the background task to complete - await asyncio.sleep(2) # Give enough time for dummy agents to complete - - # Request data, should be completed - response = await anyio.to_thread.run_sync(client.get, f"/api/v1/reports/{report_id}/data") + # Wait until completed or timeout (~4s total) + response = None + for _ in range(40): + response = await anyio.to_thread.run_sync(client.get, f"/api/v1/reports/{report_id}/data") + if response.status_code == 200: + break + await asyncio.sleep(0.1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
backend/__pycache__/main.cpython-313.pycis excluded by!**/*.pycbackend/app/api/v1/__pycache__/__init__.cpython-313.pycis excluded by!**/*.pycbackend/app/api/v1/__pycache__/routes.cpython-313.pycis excluded by!**/*.pycbackend/app/core/__pycache__/config.cpython-313.pycis excluded by!**/*.pycbackend/app/core/__pycache__/orchestrator.cpython-313.pycis excluded by!**/*.pycbackend/app/services/__pycache__/report_service.cpython-313.pycis excluded by!**/*.pycbackend/tests/__pycache__/test_routes.cpython-313-pytest-8.4.2.pycis excluded by!**/*.pyc
📒 Files selected for processing (4)
backend/app/api/v1/routes.py(2 hunks)backend/app/services/report_service.py(1 hunks)backend/main.py(1 hunks)backend/tests/test_routes.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
backend/app/api/v1/routes.py (1)
backend/app/services/report_service.py (3)
generate_report(11-20)get_report_status_from_memory(29-30)get_report_data(32-39)
🔇 Additional comments (1)
backend/main.py (1)
6-7: Import path update looks correctModule paths match repo layout; no functional change.
Overview: This PR introduces a new endpoint to fetch the final generated JSON report data.
Changes
report_id.backend/app/services/report_service.pywithin a newget_report_datafunction.Summary by CodeRabbit
New Features
Tests