Skip to content

AMI-5: Paginate the expenses list - #3

Merged
aminbaa merged 1 commit into
factory_pre_mergefrom
factory/AMI-5
Nov 28, 2026
Merged

aminbaa merged 1 commit into
factory_pre_mergefrom
factory/AMI-5

Conversation

@aminbaa

@aminbaa aminbaa commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Linear: https://linear.app/aminbaa/issue/AMI-5/paginate-the-expenses-list

Factory decision: build

Add limit/offset pagination to GET /expenses, with ordering by spent_on desc then id, and 422 on invalid values.

Plan: In app/expenses.py list_expenses, add Query params limit (default 50, ge=1, le=200) and offset (default 0, ge=0). FastAPI then returns 422 for invalid values.
Change all three role queries to ORDER BY spent_on DESC, id and append LIMIT ? OFFSET ?. Keep the WHERE clauses unchanged so visibility rules stay the same, and keep returning a plain list.
Add tests in tests/test_expenses.py for the default, the cap, ordering, offset paging, and 422 cases. Update the existing list tests if they depend on the old id order.

Why:

  • The ticket is specific: add limit and offset to GET /expenses, with defaults, a cap, an ordering rule, 422 on invalid input, and no change to visibility. The acceptance criteria are concrete enough to implement.
  • Nothing in the ticket touches money rules. Amounts are not converted or reinterpreted, and pagination only changes which rows are returned.
  • Personal data is not required for this change. The change must not expose personal_phone (docs/data.md), and a list endpoint should not add it. This is a constraint to respect during implementation, not a reason to escalate.
  • The default CODEOWNERS owner for most code is @sagard-example/expenses, so this change falls within the owning team's own code. Escalation is needed only if the work turns out to require changes to app/auth.py or .github/ (owned by @sagard-example/platform). If it does, stop and escalate those parts.
  • The rules still apply: work on a branch, open a PR, pass CI before merging, and include tests for the new pagination behaviour.
  • The requirements are specific: defaults, cap, ordering and error code are all stated.
  • The change is confined to list_expenses in app/expenses.py. That file is owned by the default expenses team, not the platform-owned auth.py or .github/.
  • No personal data or money rules are involved. Visibility logic stays the same, and the list query returns no personal_phone.
  • A cap above the limit is ambiguous: 'capped at 200' could mean clamp or 422. Rejecting values over 200 with 422 is a reasonable reading and does not need a requester to answer first.

Opened by ticket-factory. CI and review run on this PR; the factory lands it into factory_pre_merge when they pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@aminbaa
aminbaa merged commit 1a68e69 into factory_pre_merge Nov 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant