feat: add limit/pagination to battingcardratings endpoint (#135) #159
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#159
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/135-feat-add-limit-pagination-to-battingcardratings-en"
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 #135
Adds optional
limitquery parameter (default 100, max 500) toGET /api/v2/battingcardratings.Changes
limit: int = 100parameter toget_card_ratings()all_ratings.limit(max(0, min(limit, 500)))after all filters, before theif csv:branch — both CSV and JSON paths honour the limitFiles changed
app/routers_v2/battingcardratings.pyAI Code Review
Files Reviewed
app/routers_v2/battingcardratings.py(modified)Findings
Correctness
limit: int = 100added toget_card_ratings()— correct default and type.all_ratings = all_ratings.limit(max(0, min(limit, 500)))applied after all three filter branches (battingcard_id,vs_hand,cardset_id) and before theif csv:branch — both CSV and JSON response paths honour the limit correctly. ✅get_player_ratings()(lines 670–673) is a style-only change; logic is unchanged.Security
team_id+tshash check) is enforced at the top ofget_card_ratings()before the limit is applied. Thelimitparameter is fully bounds-checked before reaching the ORM.Style & Conventions
limit: int = 100is used here, while most other paginated endpoints in this series uselimit: Optional[int] = 100. PR #157 (awards) also used plainint. Both behave identically in FastAPI (the parameter is always present with a default), so this is a cosmetic inconsistency only.Suggestions
countin the JSON response reflects the limited row count, not the total matching rows. This is the pre-existing pattern across all 9 paginated endpoints — non-blocking, but a follow-up issue to add atotalfield (or renamecount) project-wide would improve pagination caller UX.limit=0returns an empty response even when records exist (max(0, min(0, 500))= 0 →LIMIT 0). Same pedantic edge case present in all prior pagination PRs; a lower bound of 1 would prevent it but is not required.Verdict: COMMENT
Implementation is correct. Limit is applied in the right place, bounds-checked identically to the other 8 paginated endpoints, and both CSV and JSON paths honour it. Minor observations (int vs Optional[int] type, count semantics, limit=0 edge case) are pre-existing patterns across the series — none block merging. Posting as COMMENT rather than APPROVED due to Gitea self-review restriction.
Automated review by Claude PR Reviewer
Implementation is correct. Limit is properly bounds-checked, applied before both CSV and JSON response paths, and follows the established pattern across all paginated endpoints. Minor observations from the automated review are pre-existing patterns — nothing blocks merging. Approving as cal.