feat: add limit/pagination to cardpositions endpoint (#142) #168
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#168
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/142-feat-add-limit-pagination-to-cardpositions-endpoin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #142
Adds
limitquery parameter toGET /api/v2/cardpositions.Changes
limit: int = 100added toget_card_positions()— default 100, consistent with all other paginated endpointsmax(0, min(limit, 500))— guards against negative values and upper bound.limit()applied after all filter branches and sort logic, beforecountand iteration — both affect count and positions listcountreflects the limited count (consistent with 13 of 14 other paginated endpoints)File changed:
app/routers_v2/cardpositions.pyTest results
No test suite — changes verified by code review. Ruff checks passed on commit.
AI Code Review
Files Reviewed
app/routers_v2/cardpositions.py(modified)Findings
Correctness
limit: int = 100, clamped viamax(0, min(limit, 500))— guards both negative values and upper bound. ✅.limit()applied after all 7 filter branches (player_id,position,r,e,arm,pb,overthrow,cardset_id) and all 4 sort branches — correct placement, bothcountandpositionslist reflect the limit. ✅Inconsistency with PR #169 (already merged)
countin the response reflects the limited count, not total matching records. This was the pre-#169 pattern. PR #169 (feat: capture total_count before limit across all paginated endpoints) has already merged intomain(commitbc6c23e) and updated 14 endpoints to computetotal_count = queryset.count()before.limit(). Thecardpositionsendpoint was not included in PR #169, so this PR will be inconsistent with the updated project-wide pattern.mainhas moved.total_countpattern here, or include it in a future housekeeping PR.Security
Style & Conventions
limit: int(notOptional[int]) — same cosmetic pattern used in PRs #157, #159, #162, #165, #166, #167. Both work identically in FastAPI. Non-blocking.Suggestions
count = all_pos.count()beforeall_pos = all_pos.limit(limit)and rename the response key tototal_count(or keepcountas total, depending on the project convention chosen in #169).Verdict: COMMENT
Implementation is functionally correct. The only notable issue is that
countreflects limited rather than total rows, which is now inconsistent with the 14 endpoints updated by the already-merged PR #169. Non-blocking, but a follow-up is recommended to aligncardpositionswith the updated project-wide pagination pattern.Automated review by Claude PR Reviewer
Approved as cal — reviewer verdict is COMMENT (non-blocking). The count inconsistency vs PR #169 pattern is noted for a follow-up cleanup PR.