store: PR review: paper-dynasty-database#52 — consolidate double-query in get_one_play

This commit is contained in:
Cal Corum 2026-03-03 21:18:19 -06:00
parent fda888e275
commit d42706d4e5

View File

@ -0,0 +1,26 @@
---
id: c9b2c04d-258a-4028-849b-a47f6168a6ab
type: workflow
title: "PR review: paper-dynasty-database#52 — consolidate double-query in get_one_play"
tags: [pr-reviewer, paper-dynasty-database, peewee, query-optimization, fastapi]
importance: 0.4
confidence: 0.8
created: "2026-03-04T03:18:19.838537+00:00"
updated: "2026-03-04T03:18:19.838537+00:00"
---
## PR #52 — fix: consolidate redundant double-query in get_one_play
**Verdict**: APPROVED (posted as COMMENT due to Gitea self-review restriction)
**File**: `app/routers_v2/stratplays.py`
### Change Summary
`get_one_play` was calling `get_or_none` (discarding the result) then `get_by_id` to fetch the same record again. Fix stores the `get_or_none` result and passes it directly to `model_to_dict`, eliminating the redundant second query.
### Key Findings
- Correct: `get_or_none` returns the model instance or None — reusing it is semantically identical
- No security issues — unauthenticated GET, int-typed param
- Clean, minimal change following project conventions
### Follow-up Note
`patch_play` at ~line 1412 has the same double-query pattern and should be fixed in a follow-up issue.