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 committed by cal
parent 110493d1b0
commit f1d289a0e9

View File

@ -1390,10 +1390,10 @@ async def get_game_summary(
@router.get("/{play_id}") @router.get("/{play_id}")
async def get_one_play(play_id: int): 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") 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 model_to_dict(play)
return r_play
@router.patch("/{play_id}") @router.patch("/{play_id}")