Repository navigation
refactor: wire accounts/fraud routers to the shared pagination envelope - #1093
Merged
gelluisaac merged 1 commit intoOct 27, 2026
Merged
gelluisaac merged 1 commit into
gelluisaac merged 1 commit into
Conversation
list_accounts, get_account_transactions, and list_fraud_alerts each hand-rolled the same (items, total, page, page_size) response shape and offset = (page - 1) * page_size math that PageParams/Page/paginate_offset in astroml.db.session (Traqora#948) already standardize. Switch all three to the shared envelope instead of reimplementing it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
astroml/db/session.pyalready definesPageParams/Page/paginate_offsetas the standard pagination envelope (issue #948), but the two routers that envelope was designed for,astroml/api/routers/accounts.pyandastroml/api/routers/fraud.py, still hand-rolled the same(items, total, page, page_size)shape and the sameoffset = (page - 1) * page_sizemath themselves, duplicating what the shared helper already does.closes #953
Changes
list_accounts,get_account_transactions(accounts.py), andlist_fraud_alerts(fraud.py) now takepage_params: PageParams = Depends()instead of separatepage/page_sizequery params, and build their response withpaginate_offset(items, total, page_params)instead of manually computingoffsetand constructing the response dict by hand.PageParamsalready validatespage/page_sizeidentically (page >= 1,1 <= page_size <= 100, defaults1/20) to theQuery(...)declarations it replaces.items,total,page,page_size).Test plan
tests/test_pagination_envelope.py:test_paginated_endpoints_take_page_params_as_a_dependency(all three endpoints takePageParamsviaDepends) andtest_router_modules_import_the_shared_envelope(assertspaginate_offsetis used and the old(page - 1) * page_sizeformula is gone from both router modules). 34/34 tests in that file pass.black --check,ruff check: clean on both touched router files and the test file.mypy: identical pre-existing errors on both router files before and after this change (verified viagit stash+ rerun), no new errors introduced.tests/performance/test_api_endpoints.py) requires the fullrequirements-api.txtdependency tree (jose, strawberry-graphql, etc.) which isn't set up in this environment; not run here, but nothing in this change touches auth, GraphQL, or request/response wire format, only the internal pagination computation.