Fix stroke index display when SI is per-tee only

has_stroke_index was derived solely from course_holes.stroke_index,
but stroke indices can also be stored as JSON on course_tees
(stroke_indices column), which is what's used at game creation to
compute strokes_allocation per player. Courses imported from the API
often have per-tee SI but no course-level hole SI, causing
has_stroke_index = False even though every player had valid stroke
data — hiding the +N badges and scorecard slash markers entirely.

Fix: fall back to checking whether any player actually has stroke
data in strokes_per_hole, applied to both game_page and game_summary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Rolf
2026-03-24 08:18:32 +01:00
parent 0be6e908e6
commit a4ce8a9d50
+2 -2
View File
@@ -404,7 +404,7 @@ async def game_summary(game_id: str, request: Request, user: dict = Depends(get_
playing_handicaps = {p["id"]: p.get("playing_handicap") for p in players}
computed = _strokes_per_hole(players, holes, hole_stroke_indices)
strokes_per_hole = {p["id"]: p["strokes_allocation"] or computed.get(p["id"], {}) for p in players}
has_stroke_index = bool(hole_stroke_indices)
has_stroke_index = bool(hole_stroke_indices) or any(strokes_per_hole.values())
skins_won, skins_hole_results, unclaimed, money_won, unclaimed_money = None, None, 0, None, 0.0
skin_value = game["skin_value"]
@@ -464,7 +464,7 @@ async def game_page(game_id: str, request: Request, user: dict = Depends(get_cur
computed = _strokes_per_hole(players, holes, hole_stroke_indices)
strokes_per_hole = {p["id"]: p["strokes_allocation"] or computed.get(p["id"], {}) for p in players}
has_stroke_index = bool(hole_stroke_indices)
has_stroke_index = bool(hole_stroke_indices) or any(strokes_per_hole.values())
return templates.TemplateResponse("games/game.html", {
"request": request, "user": user, "game": dict(game),