From 8627f3fa0cf558cc9f000711ecd7e944d51cff46 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 21 Jul 2026 16:22:29 +0200 Subject: [PATCH] Persist "closing" as its own committed status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _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 --- app/rounds/scheduler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/rounds/scheduler.py b/app/rounds/scheduler.py index 3cbc563..4fb05fc 100644 --- a/app/rounds/scheduler.py +++ b/app/rounds/scheduler.py @@ -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(