feat: per-league eligible sessions and break-even threshold settings (2.5.0)

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)
This commit is contained in:
SowinskiBraeden committed 2026-06-26 21:37:47 -07:00
1 parent 0e34600714
commit 2fc7bab183
7 files changed
+98 -31

No files matched your search

+3 -3
View File
@@ -82,9 +82,9 @@ def entry_sort_key(entry: SessionEntry) -> tuple[str, int, str]:
)
def net_result_bucket(value_cents: int) -> str:
if value_cents > BREAK_EVEN_TOLERANCE_CENTS:
def net_result_bucket(value_cents: int, tolerance_cents: int = BREAK_EVEN_TOLERANCE_CENTS) -> str:
if value_cents > tolerance_cents:
return "win"
if value_cents < -BREAK_EVEN_TOLERANCE_CENTS:
if value_cents < -tolerance_cents:
return "loss"
return "even"