feat: add team conference and division static data#677
Open
madhavcodez wants to merge 1 commit into
Open
Conversation
Author
|
CI failures are the same pre-existing Local |
Add team_conferences and team_divisions dicts to stats/library/data.py mapping the 30 NBA team_ids to their conference and division. WNBA teams are excluded since the existing teams.get_wnba_teams() set is already separated and the league has its own alignment. Add four helpers in stats/static/teams.py: - get_team_conference(team_id) -> "East" | "West" | None - get_team_division(team_id) -> "Atlantic" | "Central" | ... | None - find_teams_by_conference(conference) (case-insensitive) - find_teams_by_division(division) (case-insensitive) String values match the existing Conference and DivisionSimple parameter enums in stats/library/parameters.py so a lookup can be fed straight back into an endpoint call without remapping. Adds 14 unit tests (5 structural + 6 parametrized lookup + disjoint-membership + case-insensitivity + unknown-input) for the new data and helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two static lookups for NBA team alignment and four helpers to query them.
data.team_conferences:team_id -> "East" | "West"(30 NBA teams)data.team_divisions:team_id -> "Atlantic" | "Central" | "Southeast" | "Northwest" | "Pacific" | "Southwest"static.teams.get_team_conference(team_id)static.teams.get_team_division(team_id)static.teams.find_teams_by_conference(conference)(case-insensitive)static.teams.find_teams_by_division(division)(case-insensitive)WNBA teams are intentionally excluded, matching how
get_wnba_teams()is already kept separate.Why
stats/library/parameters.pyalready definesConferenceandDivisionSimple, but those are input enums for endpoint query params, not a way to ask "which conference is this team in?". There is no existing path from ateam_idto its conference or division without hardcoding it in user code.This fills that gap with the same shape as the existing
get_team_by_id/find_teams_by_*helpers, so it reads as a natural extension rather than a new surface.The string values are deliberately aligned with the param enums, so a typical chain works without remapping:
Maintenance
NBA conference/division alignment has been stable since the 2004-05 realignment, so this is effectively static reference data with no expected churn.
Tests
14 new unit tests in
tests/unit/stats/static/test_static_data.pycovering:Nonefor unknown ids (NBA and WNBA)find_teams_by_*is case-insensitive and returns the right counts (15/15 by conference, 5 per division){GSW, LAC, LAL, PHX, SAC}membership[]rather than silently matchingNone,"") is tolerated rather than raisingFull suite: 534 passing locally. The 2 pre-existing
tests/unit/live/endpoints/test_get_request_urlfailures (stale 2021 game id) reproduce onmasterand are unrelated, as noted in #671 and #676.ruff checkandruff format --checkare clean.Scope
No changes to endpoints, parameters, HTTP layer, or existing helpers. Additive only.