feat: add limit/pagination to scout_opportunities endpoint (#148) #154
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#154
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/148-feat-add-limit-pagination-to-scout-opportunities-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 #148
Adds
limitquery parameter (default 100, max 500) toGET /api/v2/scout_opportunities.Changes
app/routers_v2/scout_opportunities.py: Addedlimit: Optional[int] = 100parameter; capped viamax(0, min(limit, 500)); applied as.limit(limit)before query executionfnimport (required to pass ruff pre-commit hook)Behaviour
Other observations
countin the response reflects the limited count, not the total matching rows — same pre-existing pattern as notifications, scout_claims, and rewards endpointsAI Code Review
Files Reviewed
app/routers_v2/scout_opportunities.py(modified)Findings
Correctness
limit: Optional[int] = 100added as a query param withmax(0, min(limit, 500))clamping applied before all filters run and.limit(limit)applied after allwhere()clauses — correct ordering.fnremoval is valid: confirmed unused throughout the file; no calls reference it.limit=0returns an empty response even when matching records exist (lower bound ofmax(0, ...)admits zero). A caller who accidentally passeslimit=0gets no results with no error. Usingmax(1, min(limit, 500))would prevent this — same pedantic edge case flagged in PRs #149 and #152.countin the response reflects the limited count, not the total number of matching rows. Acknowledged in the PR body; consistent with pre-existing pattern across/notifs,/scout_claims, and/rewards. Non-blocking, but worth a follow-up issue to standardise pagination metadata across all endpoints.Security
limitis typed asint; FastAPI validates it at the boundary. The clamp prevents pathological queries.Style & Conventions
Suggestions
/notifs,/scout_claims,/rewards,/scout_opportunities) all share the samecount-reflects-limited-count behaviour. A single follow-up issue to add atotalfield (or renamecounttoreturned_count) would clean this up project-wide rather than one endpoint at a time.Verdict: COMMENT
Clean, minimal, correct. Consistent with the established pagination pattern. The two minor observations (zero-limit edge case, misleading
count) are pre-existing across the series and are acknowledged in the PR body — nothing blocks merging.Automated review by Claude PR Reviewer
Approved. Limit lower-bound fix (max(1,...)) looks correct — addresses the reviewer edge-case note cleanly.