fix(server): populate games_v2 metadata on game start

update_game_started (started_at, num_players, num_rounds, player_ids)
was defined in event_store but had zero callers. 289/289 staging games
had those fields NULL — queries that joined on them returned garbage,
and the denormalized player_ids GIN index was dead weight.

log_game_start now calls create_game THEN update_game_started in one
async task. If create fails, update is skipped (row doesn't exist).
handlers.py passes num_rounds and player_ids through at call time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-04-18 00:41:58 -04:00
parent d5f8eef6b3
commit 8030a3c171
3 changed files with 142 additions and 36 deletions

View File

@@ -215,6 +215,8 @@ async def handle_start_game(data: dict, ctx: ConnectionContext, *, broadcast_gam
ctx.current_room.game_log_id = game_logger.log_game_start(
room_code=ctx.current_room.code,
num_players=len(ctx.current_room.players),
num_rounds=num_rounds,
player_ids=[p.id for p in ctx.current_room.game.players],
options=options,
)