fix: consolidate redundant double-query in get_one_play (#14)

Reuse the result of get_or_none instead of discarding it and calling
get_by_id again, eliminating one unnecessary round-trip per request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-03 21:02:47 -06:00
parent 761c0a6dab
commit d12ce52d65

View File

@ -1395,10 +1395,10 @@ async def get_game_summary(
@router.get("/{play_id}")
async def get_one_play(play_id: int):
if StratPlay.get_or_none(StratPlay.id == play_id) is None:
play = StratPlay.get_or_none(StratPlay.id == play_id)
if play is None:
raise HTTPException(status_code=404, detail=f"Play ID {play_id} not found")
r_play = model_to_dict(StratPlay.get_by_id(play_id))
return r_play
return model_to_dict(play)
@router.patch("/{play_id}")