feat: add limit/pagination to pitchingcardratings endpoint (#136) #161
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#161
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/136-feat-add-limit-pagination-to-pitchingcardratings-e"
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 #136
Adds optional
limit: intquery parameter (default 100, max 500) toGET /api/v2/pitchingcardratings.Changes
app/routers_v2/pitchingcardratings.py: Addedlimit: int = 100parameter toget_card_ratings(); limit capped viamax(0, min(limit, 500))applied after all filters and before the CSV/JSON branch — both response paths honour the limit.Other observations
get_scouting_dfs()andpost_calc_scouting()/post_calc_basic()— these were auto-fixed to unblock the commit. Non-functional.countin the JSON response reflects the limited count (not total matching rows) — consistent with the pre-existing pattern across all other paginated endpoints in this repo.AI Code Review
Files Reviewed
app/routers_v2/pitchingcardratings.py(modified)Findings
Correctness
limit: int = 100added toget_card_ratings()function signature — matches PR description exactly.all_ratings = all_ratings.limit(max(0, min(limit, 500)))applied after all three filter branches (pitchingcard_id,vs_hand,cardset_id) and before theif csv:branch — both CSV and JSON response paths honour the limit. ✅max(0, min(limit, 500))correctly guards against negative values and enforces the 500 upper bound. ✅intused directly, noOptionalneeded). ✅Security
limitis an integer parameter validated by FastAPI type coercion before it reaches Peewee..limit()with an integer is safe from injection.Style & Conventions
limit: int = 100(notOptional[int]) — minor inconsistency with most other paginated endpoints in this repo that useOptional[int]. Both are functionally identical in FastAPI. Non-blocking; follows the same pattern as PR #157 (awards) and PR #159 (battingcardratings).countin the JSON response reflects the limited count, not total matching rows — consistent with the pre-existing pattern across all prior paginated endpoints. Non-blocking.limit=0passesmax(0, min(0, 500))= 0 → PeeweeLIMIT 0→ empty result. Same pedantic edge case as all prior pagination PRs. Non-blocking.get_scouting_dfs(),post_calc_scouting(),post_calc_basic()) are non-functional cleanup. Correct.Suggestions
Verdict: COMMENT
Implementation is correct and follows the established pagination pattern. Posting as COMMENT rather than APPROVED due to Gitea self-review restriction.
Automated review by Claude PR Reviewer
LGTM — clean pagination implementation consistent with the established pattern across other endpoints. Ruff fixes are a bonus.