Add draw_animation_seconds config and expose winner info during a round

RoundConfig gains draw_animation_seconds (default 20) — the minimum
time the frontend's "estrazione in corso" animation plays before
revealing a winner. It's purely a UI cue: the real draw still waits for
a confirmed block for its entropy (rounds/scheduler.py), which usually
takes much longer than this value, so it only ever extends the
animation, never truncates the real wait.

GET /rounds/current now also returns draw_animation_seconds,
winner_user_id and winner_amount_sats (all populated once the
scheduler sets them on the round, i.e. from "paying_out" onward) so a
client can determine and reveal the outcome. GET /users/me now returns
the user's own id, needed client-side to compare against winner_user_id.

Admin config CRUD refactored to a shared field tuple (_CONFIG_FIELDS)
instead of repeating the same 7-then-8 field list three times.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 16:04:02 +02:00
co-authored by Claude Sonnet 5
parent b52a8023de
commit 669c3fb714
5 changed files with 71 additions and 20 deletions
@@ -0,0 +1,37 @@
"""add draw_animation_seconds to round_config
Revision ID: 1db52f3a7c67
Revises: 53cc70d16e63
Create Date: 2026-07-21 15:45:16.434942
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '1db52f3a7c67'
down_revision: Union[str, Sequence[str], None] = '53cc70d16e63'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# server_default backfills the existing singleton row (if any); dropped right
# after so new rows go through the ORM default instead of a stale constant.
op.add_column(
'round_config', sa.Column('draw_animation_seconds', sa.Integer(), nullable=False, server_default='20')
)
with op.batch_alter_table('round_config') as batch_op:
batch_op.alter_column('draw_animation_seconds', server_default=None)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('round_config', 'draw_animation_seconds')
# ### end Alembic commands ###