Persist "closing" as its own committed status

_close_and_draw set round_.status = "closing" but then immediately
overwrote it in memory with "closed" (no participants) or "drawing"
(with participants) before the first session.commit() — so "closing"
was never actually written to the database, only ever visible in the
ORM object's transient in-memory state. GET /rounds/current (and the
frontend's "in chiusura" label) could never observe it.

Committing right after setting "closing"/closed_at, before querying
participants, makes it a real, briefly-observable state like the
others in the round lifecycle.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 16:22:29 +02:00
co-authored by Claude Sonnet 5
parent 4b510f312f
commit 8627f3fa0c
+4
View File
@@ -77,6 +77,10 @@ class RoundScheduler:
round_ = await session.get(Round, round_id)
round_.status = "closing"
round_.closed_at = datetime.now(timezone.utc)
# Committed on its own so "closing" is actually observable (e.g. by
# /rounds/current) instead of being overwritten in memory by "closed"
# or "drawing" below before ever reaching the database.
await session.commit()
participants = (
await session.scalars(