Skip to content

Commit

Permalink
Adds Teams.team_summary() to also include 'franchise_id" (#62)
Browse files Browse the repository at this point in the history
* Update:
- Fixes 61.

This updates Teams.team_summary() to also include 'franchise_id', which is used for the stat builder feature for Franchise querying.

- Version bump


* addition: README update
  • Loading branch information
coreyjs authored Aug 16, 2024
1 parent abd0337 commit d4bfeef
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 245 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ filters = [
PositionQuery(position=PositionTypes.ALL_FORWARDS),
ShootCatchesQuery(shoot_catch="L"),
HomeRoadQuery(home_road="H"),
FranchiseQuery(franchise_id="1"),
StatusQuery(is_active=True) #for active players OR for HOF players StatusQuery(is_hall_of_fame=True),
FranchiseQuery(franchise_id="1"), # these ids can be found via the client.teams.teams_info() endpoint.
StatusQuery(is_active=True), # for active players OR for HOF players StatusQuery(is_hall_of_fame=True),
OpponentQuery(opponent_franchise_id="2"),
ExperienceQuery(is_rookie=True), # for rookies || ExperienceQuery(is_rookie=False) #for veteran
DecisionQuery(decision="W") # OR DecisionQuery(decision="L") OR DecisionQuery(decision="O")
Expand Down
2 changes: 1 addition & 1 deletion nhlpy/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Should this be driven by the main pyproject.toml file? yes, is it super convoluted? yes, can it wait? sure

__version__ = "2.8.0"
__version__ = "2.9.0"
240 changes: 0 additions & 240 deletions nhlpy/api/helpers.py

This file was deleted.

12 changes: 12 additions & 0 deletions nhlpy/api/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ def teams_info(self) -> dict:
"""
data_resource = importlib.resources.files("nhlpy") / "data"
teams_info = json.loads((data_resource / "teams_20232024.json").read_text())["teams"]

# We also need to get "franchise_id", which is different than team_id. This is used in the stats.
franchises = self.all_franchises()
for f in franchises:
for team in teams_info:
if "Canadiens" in f["fullName"] and "Canadiens" in team["name"]:
team["franchise_id"] = f["id"]
continue

if f["fullName"] == team["name"]:
team["franchise_id"] = f["id"]

return teams_info

def roster(self, team_abbr: str, season: str) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion nhlpy/data/teams_20232024.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{ "id": "4", "abbreviation": "PHI", "name": "Philadelphia Flyers" },
{ "id": "5", "abbreviation": "PIT", "name": "Pittsburgh Penguins" },
{ "id": "28", "abbreviation": "SJS", "name": "San Jose Sharks" },
{ "id": "55", "abbreviation": "SEA", "name": "Seattle Kraken"},
{ "id": "55", "abbreviation": "SEA", "name": "Seattle Kraken"},
{ "id": "19", "abbreviation": "STL", "name": "St. Louis Blues" },
{ "id": "14", "abbreviation": "TBL", "name": "Tampa Bay Lightning" },
{ "id": "10", "abbreviation": "TOR", "name": "Toronto Maple Leafs" },
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "nhl-api-py"
version = "2.8.0"
version = "2.9.0"
description = "NHL API (Updated for 2024/2025) and EDGE Stats. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods as well as pythonic query builder for more indepth EDGE stats."
authors = ["Corey Schaf <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit d4bfeef

Please sign in to comment.