Skip to content

Waivers: games_next_7d from the public scoreboard when the pro-games block is absent - #179

Open
warnerktsang wants to merge 2 commits into
mainfrom
espn-waivers-scoreboard-schedule
Open

warnerktsang wants to merge 2 commits into
mainfrom
espn-waivers-scoreboard-schedule

Conversation

@warnerktsang

Copy link
Copy Markdown
Collaborator

Problem

GET /espn/waivers reports games_next_7d = 0 for every player this season: the league payload carries no proGamesByScoringPeriod block, and the scoreboard fallback in _team_games_next_7d could only anchor period dates off that same block — no block, no anchor, no schedule. The schedule-edge pocket-pick rule has been dormant.

Fix

Derive the schedule from ESPN's public scoreboard (the ScoreboardClient the waivers route already injects):

  • get_waivers now tracks a period anchor (period, date): captured when the current period itself is derived from the scoreboard's season start, and otherwise computed from first_regular_season_date when the payload carries no dated schedule at all and the period came straight from status. The anchor lookup is wrapped so a scoreboard outage there degrades to today's behaviour instead of failing the report.
  • _team_games_next_7d(..., anchor=...) uses the block's own date map when it publishes one (unchanged precedence — the block stays authoritative), else the supplied anchor, to date each upcoming period for scoreboard.teams_on(day).
  • Coverage is real: a period counts as covered only when a source answered for it, so the notes line now reports the true number (games_next_7d covers N of the next 7 days (the rest could not be determined); counts may understate).
  • The pocket-pick schedule-edge rule itself is untouched — it activates naturally now that counts flow.

Notes / assumptions

  • Team-id spaces line up, no remapping needed: scoreboard competitor ids are ESPN's canonical NBA team ids — the same space as fantasy proTeamId (scoreboard.py's documented contract). Counts are keyed by id end to end; the known 27/28 abbreviation discrepancy is display-only (PRO_TEAM_ABBR untouched).
  • Cost: at most ~7 day-fetches per waivers call (plus the season-start month fetch, cached client-side and usually already paid by the period derivation) on top of the existing ~15 — no per-player fetches.
  • The existing FakeScoreboard test double gained a teams_on (empty slate) so it models the full injected interface get_waivers now uses.

Tests

Four new tests in test_espn_waivers.py with a programmable FakeScheduleScoreboard (its slate mirrors the fixture pro-games block, so expected counts match the block-based tests):

  • full week from the scoreboard with the block absent — free-agent and drop-candidate counts, no shortfall note, schedule-edge pick fires;
  • anchor reuse when the period itself was scoreboard-derived;
  • partial coverage (3 of 7 days raise) — counts from the 4 fetched days only, note says covers 4 of the next 7 days, report intact;
  • total scoreboard outage — all counts 0, covers 0 of the next 7 days note, report intact.

ESPN scope locally: 531 passed (527 baseline + 4 new). Read-only; no new endpoints; no migration.

warnerktsang added a commit that referenced this pull request Oct 30, 2026
warnerktsang added a commit that referenced this pull request Oct 30, 2026
* ESPN waivers: scoreboard-derived games_next_7d schedule (redo of #179 on current main)

* Tests for scoreboard-derived games_next_7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant