Closes #196 Add pagination and stable ordering to expense and settlement lists - #325
Conversation
|
@Fury03 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
MergeKeeper review unavailable AI provider review response did not contain valid JSON No approval or merge action was taken. |
6949f4f to
226eec4
Compare
|
MergeKeeper review Scope: in scope for linked issue Successfully added the paginated GET /groups/:id/settlements endpoint with proper membership checks, cursor handling, documentation, and comprehensive test coverage. Reviewed commit: |
|
MergeKeeper merge status Status: blocked Reason: Next steps:
|
Closes mergepay#196 Adds `GET /groups/:id/settlements` with cursor-based pagination and deterministic (createdAt, id) ordering, matching the shared pagination contract used by every other list endpoint. - New route scoped to authenticated group membership - Uses existing pagination primitives (cursorFilter, cursorOrderBy, takeForPage, buildPage) for bounded, consistent queries - Enforces maximum page size server-side - Membership checked before any row is read - 3 contract tests added to shared pagination suite - 5 dedicated settlement-list tests (first page, cursor resume, bounded query, non-member rejection, cursor-scoping) - API contract docs updated 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
226eec4 to
69d3650
Compare
Closes #196
Problem Statement
Settlement records within a group have no dedicated list endpoint with cursor-based pagination. While the ledger endpoint merges expenses, settlements, and treasury transactions, clients that specifically need to list settlements for a group must either use the merged ledger (which interleaves different record types) or the cross-group history endpoint (which scopes to the authenticated user rather than the group).
Solution Comparison and Decision
Option A: Add pagination to a new
GET /settlementsendpoint — This would list all settlements across all groups, which is not what the issue describes. The issue asks for pagination on "group expenses or settlement records," meaning per-group scoping.Option B: Rely on the ledger endpoint — The ledger merges expenses, settlements, and treasury transactions. It already has pagination, but a client that only needs settlements must fetch and filter mixed results, wasting bandwidth and making cursor-based pagination impossible across types.
Option C: Add
GET /groups/:id/settlementswith shared pagination (chosen) — A dedicated endpoint scoped to the group, using the same cursor-based pagination contract as every other list endpoint. This gives clients a stable, deterministic way to page through settlements without mixing types or relying on cross-group history.The Change
New route in
src/routes/settlements.ts:GET /groups/:id/settlementsKey behaviors:
(createdAt, id)ordering handles equal timestamps safelylimit + 1row fetch computeshasMorewithout a count queryCompatibility Note
No
INTERFACE_VERSIONchange. This is an additive new endpoint that does not modify existing routes or response shapes. Existing clients are unaffected.Incidental Fixes
GET /groups/:id/settlementsto the shared pagination contract documentation indocs/api-contract.md.Testing
New tests (in
tests/pagination-contract.test.ts):Test results: All 757 tests pass (57 test files), including 46 pagination-contract tests.
Additional Notes
Settlement records were previously only accessible through the merged ledger endpoint (
GET /groups/:id/ledger) or the cross-group history endpoint (GET /history). This PR adds the dedicated per-group list endpoint that settlement-specific clients need.