fix: consolidate redundant double-query in get_one_play (#14) #52
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#52
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database#14"
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?
Summary
Fixes #14.
get_one_playwas making two round-trips to the database for a single record:get_or_none(...)— to check existence, result discardedget_by_id(...)— to fetch the same record againThe fix reuses the result from
get_or_none, eliminating the redundant second query.Changes
app/routers_v2/stratplays.py: Storeget_or_noneresult and return it directlyTest Results
No test suite — verified by reading back the modified function.
AI Code Review
Files Reviewed
app/routers_v2/stratplays.py(modified)Findings
Correctness
get_or_nonereturns the model instance (orNone), so storing it and passing directly tomodel_to_dictis semantically identical to the original two-query pattern — with one fewer round-trip to the database.Nonecheck raises the sameHTTPException.r_playvariable is a minor cleanup with no behavioral change.Security
play_idis typed asint, so no injection risk.Style & Conventions
Suggestions
patch_playendpoint directly below (~line 1412) has the same double-query pattern (get_or_noneresult discarded, then a second fetch). Worth a follow-up issue to apply the same fix there for consistency.Verdict: APPROVED
Clean, correct optimization. Eliminates a redundant DB round-trip with no behavioral change. Exactly what the PR claims.
Automated review by Claude PR Reviewer
d12ce52d65tof1d289a0e9