Fix MLB standings 406 error and refactor ESPN adapter shared code #62

Merged
chrisp merged 3 commits from fix/mlb-standings-espn-refactor into main 2026-06-01 03:31:19 +00:00

3 commits

Author SHA1 Message Date
Chris Parsons
3ebdd16b60 Fix intermittent test timeouts in simulator-inputs and llws-simulator
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m27s
🚀 Deploy / ʦ TypeScript (pull_request) Successful in 1m16s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 48s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
simulator-inputs: move dynamic import to top level so heavy module
initialization happens during file load (no timeout) instead of inside
the test body.

llws-simulator: make iteration count injectable via constructor
(default 50_000 for production, tests pass 1_000). Cuts test suite
from ~4s per test to <150ms for all 21 tests combined.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 20:20:24 -07:00
Chris Parsons
880b7faa6b Fix TypeScript errors: cast response.json() to EspnStandingsResponse
Some checks failed
🚀 Deploy / 🧪 Test (pull_request) Failing after 2m39s
🚀 Deploy / ʦ TypeScript (pull_request) Successful in 1m19s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 51s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 19:54:23 -07:00
Chris Parsons
e353c17a0b Fix MLB standings 406 error and refactor ESPN adapter shared code
Some checks failed
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m28s
🚀 Deploy / ʦ TypeScript (pull_request) Failing after 1m9s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 46s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
- Switch MLB standings from deprecated statsapi.mlb.com to ESPN API
  (same source as NBA, WNBA, MLS — no auth required)
- Extract shared espn.ts utility: EspnStat/Team/Entry/Group/Response
  interfaces, statsMap(), flattenEspnStandings(), parseConferenceRank(),
  sortByWinLoss(); removes 4× duplication across adapters
- Fix parseConferenceRank falsy-zero bug (|| undefined → isNaN guard)
- Add stable alphabetical tiebreaker to MLB, NBA, WNBA sort comparators
- Fix winPct silent-zero: fall back to wins/(wins+losses) if ESPN omits stat
- Pre-build statsMap once per entry before sorting in all adapters
- Fix WNBA parseEntry to accept pre-computed sm instead of rebuilding it
- Restore and update gamesBack tests (ESPN returns numeric 0 for leaders,
  not the old API's "-" string)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 18:18:15 -07:00