brackt/drizzle/0104_chief_boom_boom.sql

1 line
61 B
MySQL
Raw Permalink Normal View History

Add MLS sport simulator (mls_bracket) (#422) * Add MLS sport simulator (mls_bracket) Adds Major League Soccer as a draftable sport with a full-season Monte Carlo simulator. Models both preseason regular-season projection (34 games across Eastern and Western conferences) and the MLS Cup Playoffs bracket, including the Wild Card (single game + PKs), Round 1 best-of-3 series, Conference Semis/Finals (single game), and MLS Cup. P1–P8 mapping: MLS Cup winner, finalist, Conference Finals losers, Conference Semifinals losers. Conference assignment reads from regularSeasonStandings.conference or falls back to the region simulator input ("Eastern"/"Western"). Admin inputs: projectedTablePoints (primary, max 102 for 34×3), with derivation chain to sourceElo via existing input-policy; sourceOdds as alternative. No hardcoded team data — all inputs are admin-managed per season. - database/schema.ts: add mls_bracket to simulatorTypeEnum - drizzle/0104_chief_boom_boom.sql: migration for the new enum value - mls-simulator.ts: MLSSimulator + exported pure helpers for testability - registry.ts / manifest.ts / simulator-config.ts: register mls_bracket - mls-simulator.test.ts: 38 unit tests covering all helpers and sync checks https://claude.ai/code/session_015wkBJ3SYGcMGjsddKKGkwa * Fix MLS simulator: config loading, sourceOdds fallback, normalization Three issues found in code review comparing against EPL and NFL simulators: 1. Load simulator config from DB via getSportsSeasonSimulatorConfig so admins can override iterations, seasonGames, parityFactor, drawRates per season without code changes. Previously all constants were hardcoded. 2. Add sourceOdds → convertFuturesToElo fallback when no sourceElo is present. EPL and NFL both do this; MLS was throwing immediately instead of attempting the odds conversion that the manifest declares as optional. 3. Call normalizeSimulationResultColumns before returning results, matching EPL's local normalization pattern for consistency (runner also normalizes globally, but EPL calls it locally too). https://claude.ai/code/session_015wkBJ3SYGcMGjsddKKGkwa * Polish MLS simulator: configNumber zero, logger warning, Map lookup Three small fixes from secondary code review: 1. configNumber: allow value >= 0 (not just > 0) so admins can legitimately set baseDrawRate or drawDecay to 0 without the value being silently discarded and replaced with the default. 2. Add logger.warn when a participant is excluded from simulation due to a missing Elo rating, matching the NLL bracket-aware pattern. Gives admins a visible signal instead of a silent exclusion. 3. getBySeeds: build a Map once instead of calling Array.find() per seed. Eliminates 4M linear scans across 50k iterations for a 9- element array — trivially fast either way, but Map is the right tool. https://claude.ai/code/session_015wkBJ3SYGcMGjsddKKGkwa --------- Co-authored-by: Claude <noreply@anthropic.com>
2026-05-14 12:45:53 -07:00
ALTER TYPE "public"."simulator_type" ADD VALUE 'mls_bracket';