Refactor and optimize: deduplicate, batch queries, fix bugs

- Remove unused DATABASE_PATH import from games.py
- Extract _new_game_context(db) helper to deduplicate GET/POST error path
- Extract _parse_hole_form() helper to deduplicate hole validation in create/edit course
- Batch N+1 player handicap and tee queries in create_game into two IN() queries
- Fix hole count import bug: use max() across all tees instead of first match
- Fix migration exception handling: re-raise unless "duplicate column name"
- Cache calcSkins() result in _skinsCache; invalidate on score/skip changes
- Collapse two identical Next buttons into one in new_game.html
- Fix stale skinDoubleBackNine checkbox: reset on mode change, use x-model

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Rolf
2026-03-23 22:52:45 +01:00
parent d81d6a2d3c
commit 0be6e908e6
5 changed files with 101 additions and 118 deletions
+3 -2
View File
@@ -139,5 +139,6 @@ async def init_db():
try:
await db.execute(migration)
await db.commit()
except Exception:
pass # column already exists
except Exception as e:
if "duplicate column name" not in str(e).lower():
raise