Skip to content

fix(nrl-scoreboard): match favorite/exclude teams by ESPN team ID, not abbreviation#189

Open
ChuckBuilds wants to merge 2 commits into
claude/nrl-scoreboardfrom
claude/nrl-team-ids-abbrev-lepchm
Open

fix(nrl-scoreboard): match favorite/exclude teams by ESPN team ID, not abbreviation#189
ChuckBuilds wants to merge 2 commits into
claude/nrl-scoreboardfrom
claude/nrl-team-ids-abbrev-lepchm

Conversation

@ChuckBuilds

Copy link
Copy Markdown
Owner

Summary

Fixes a bug reported by a user testing PR #182 (NRL scoreboard):

One thing I found with the NRL is that you need to use team id and not abbreviations - there are two "NEW" and two "CAN"

ESPN's rugby-league team abbreviations are not unique: NEW is used by both the Newcastle Knights and the New Zealand Warriors, and CAN is used by both the Canberra Raiders and the Canterbury Bulldogs. favorite_teams/exclude_teams matching previously compared against home_abbr/away_abbr, so configuring one of these abbreviations silently matched both teams.

Fix

  • dynamic_team_resolver.py: DynamicTeamResolver now fetches the NRL team list from ESPN once (in-process cache, 24h TTL) and resolves each configured favorite_teams/exclude_teams entry to a unique ESPN team ID:
    • Numeric entries pass through as-is (already an ID).
    • Full team name / location / nickname / short name matches resolve unambiguously.
    • A unique abbreviation still resolves.
    • An ambiguous abbreviation (e.g. NEW, CAN) is not silently resolved to either team — it logs an error naming both candidate teams and instructs the user to use the full team name or ID instead.
    • If the team list can't be fetched (offline, ESPN outage) it falls back to a stale cache, then to the raw configured value, with a warning.
  • sports.py / manager.py: every favorite/exclude membership check now compares home_id/away_id (already extracted per-game) against the resolved team-ID list, instead of home_abbr/away_abbr. This covers live rotation filtering/classification, live-priority weighting, goal/win celebrations, and upcoming/recent game selection and filtering.
  • config_schema.json / README.md: updated descriptions to steer users toward full team names or ESPN team IDs, with the NEW/CAN collision called out explicitly.
  • test/harness.json: favorite_teams switched from ["PEN", "BRI"] to the corresponding team IDs (["18", "16"]) so the offline test harness doesn't depend on a live network fetch to resolve favorites.
  • test_nrl_plugin.py: added TestDynamicTeamResolverAbbreviationCollisions covering the ambiguous-abbreviation case, full-name disambiguation, unique-abbreviation resolution, numeric ID passthrough, and fetch-failure fallback (mocks requests.get, no network needed).

Test plan

  • python3 -m py_compile all touched .py files — passes.
  • python3 test_nrl_plugin.py — 11/11 tests pass (6 pre-existing + 5 new).
  • manifest.json, config_schema.json, test/harness.json all parse.
  • python scripts/check_module_collisions.py — no cross-plugin collisions.
  • python update_registry.py — registry synced, version bumped to 1.0.1.
  • Not run: the core check_plugin.py cross-size harness (requires a LEDMatrix core checkout — none available in this environment).
  • Not run: live on-device verification against the real ESPN team-list endpoint (this sandbox's egress policy blocks site.api.espn.com).

🤖 Generated with Claude Code


Generated by Claude Code

…t abbreviation

NRL's ESPN abbreviations aren't unique — "NEW" is both Newcastle Knights and
New Zealand Warriors, "CAN" is both Canberra Raiders and Canterbury Bulldogs.
Matching favorite_teams/exclude_teams by abbreviation silently conflated
these teams. DynamicTeamResolver now resolves configured team names/IDs to
unique ESPN team IDs (fetching the NRL team list, with a name/ID lookup and
an explicit warning on ambiguous or unresolved abbreviations), and every
favorite/exclude membership check in sports.py and manager.py now compares
against home_id/away_id instead of home_abbr/away_abbr.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rxy8kp5foWywPeBsCmY1Uo
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2dfa7ce-ba6e-4a7b-a000-b96ce1803fb6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/nrl-team-ids-abbrev-lepchm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The plugin safety harness (LEDMatrix core's check_plugin.py) expects
mock_data in test/harness.json to be a path string to a fixture file, not
inline JSON - it does Path(plugin_dir) / mock_data, which raises TypeError
against a dict. Every other plugin harness in this repo follows the
path convention (e.g. ledmatrix-weather's test/fixtures/mock.json); this
plugin's harness.json had the ESPN response inlined instead, which was
failing the "safety" CI check on both this PR and #182.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rxy8kp5foWywPeBsCmY1Uo
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 35 complexity

Metric Results
Complexity 35

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

2 participants