-
Notifications
You must be signed in to change notification settings - Fork 1
API for Report Flow #174
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
API for Report Flow #174
Conversation
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.
Thanks for your work on this @SakshiKekre! There are a few points where I'd recommend changes (basically only around using conversion adapters) and a couple questions, otherwise we'll be good to go.
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.
Had a few requested changes, plus I believe a couple comments remain incomplete.
Thanks for pointing this out in all spots where ID is used. It’s helpful because I don’t have to dig through each line myself. Mentioning my thoughts here for all comments relevant to ID in the URL: While I agree that URLs for PATCH shouldn’t include path parameters where possible, in this case, the reportId is an identifier, not part of the patch data itself to go in the body. The path identifies which resource is being updated, while the body describes what is updated. This aligns with common REST conventions:
Removing the ID from the path would make the PATCH act on the collection (/report), which is less canonical and inconsistent with the rest of the CRUD model. Given that, I’d prefer to keep the reportId in the path across these occurrences. BTW, this also makes me want to rename the endpoints from report -> reports and simulation -> simulations to better reflect collections. |
56a88a7
to
4a56931
Compare
Note: DO NOT MERGE until API update (https://github.com/PolicyEngine/policyengine-api/actions/runs/17701223907/attempts/1) is fully deployed |
- Fix ReportMetadata to use 'id' instead of 'report_id' (matches backend auto-increment) - Make Report.reportId optional like Policy.id (populated after creation) - Simplify ReportCreationPayload to only include simulation IDs (backend generates ID/timestamps) - Update ReportSetOutputPayload to remove redundant fields (ID in URL path) - Update ReportAdapter to handle proper ID mapping and simplified payloads - Add report API functions: fetchReportById, createReport, updateReport - Fix all tests and mocks to match corrected types - All report adapter and API tests passing (18 total) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Fix type misalignments between frontend and backend API - Implement CRUD operations: fetchReportById, createReport, updateReport - Add comprehensive test coverage (18 tests: 12 adapter + 6 API) - Align ID handling with database auto-increment pattern - Simplify creation payloads to only required fields 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
4a56931
to
c0950a3
Compare
Summary
Implemented report API functionality with corrected ID handling and proper alignment between frontend types and backend API endpoints.
TODO: API for calculation endpoint
Key Changes
Type Alignment Fixes
New API Functions
Updated Adapters
Testing