Add two configurable leaderboard settings per league, replacing the global constants with per-row DB columns: - eligible_min_sessions (default 3): minimum sessions before a player ranks on the main leaderboard rather than showing as provisional - break_even_cents (default 100 = $1.00): sessions within ±this of $0 net are classified as break-even rather than a win or loss Changes: - Migration 0003 adds both columns with server defaults for existing leagues - League DB model gains eligible_min_sessions and break_even_cents columns - net_result_bucket() and build_leaderboard() accept optional tolerance param - summarize_player_runs() passes tolerance to net_result_bucket for streaks - League leaderboard route reads values from the league row instead of config - League settings form exposes both fields with validation (1-100 sessions, $0.00-$100.00 threshold)
33 lines
887 B
Python
33 lines
887 B
Python
"""add per-league eligible_min_sessions and break_even_cents
|
|
|
|
Revision ID: 0003_league_settings
|
|
Revises: 0002_league_public_key
|
|
Create Date: 2026-06-26
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = "0003_league_settings"
|
|
down_revision = "0002_league_public_key"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
with op.batch_alter_table("leagues") as batch_op:
|
|
batch_op.add_column(sa.Column(
|
|
"eligible_min_sessions", sa.Integer(), nullable=False, server_default="3"
|
|
))
|
|
batch_op.add_column(sa.Column(
|
|
"break_even_cents", sa.Integer(), nullable=False, server_default="100"
|
|
))
|
|
|
|
|
|
def downgrade() -> None:
|
|
with op.batch_alter_table("leagues") as batch_op:
|
|
batch_op.drop_column("break_even_cents")
|
|
batch_op.drop_column("eligible_min_sessions")
|