fix(lobby): gate reveal promotion on resolved rounds
All checks were successful
CI / test-and-quality (pull_request) Successful in 2m58s
CI / test-and-quality (push) Successful in 2m59s

This commit is contained in:
2026-03-16 03:45:10 +00:00
parent bfa4ab859c
commit 624bcd602b

View File

@@ -247,6 +247,16 @@ def _maybe_promote_reveal_to_scoreboard(session: GameSession) -> GameSession:
if current_round_question is None: if current_round_question is None:
return session return session
players_count = Player.objects.filter(session=session).count()
guess_count = Guess.objects.filter(round_question=current_round_question).count()
has_score_events = ScoreEvent.objects.filter(
session=session,
meta__round_question_id=current_round_question.id,
).exists()
reveal_is_resolved = has_score_events or (players_count > 0 and guess_count >= players_count)
if not reveal_is_resolved:
return session
with transaction.atomic(): with transaction.atomic():
locked_session = GameSession.objects.select_for_update().get(pk=session.pk) locked_session = GameSession.objects.select_for_update().get(pk=session.pk)
if locked_session.status != GameSession.Status.REVEAL: if locked_session.status != GameSession.Status.REVEAL: