Skip to content

Commit

Permalink
Update team owners
Browse files Browse the repository at this point in the history
Team owner name was no longer part of team class. Use owner map to map from owner id to owner name.
  • Loading branch information
Kjeldgaard committed Oct 27, 2023
1 parent 46c5a9c commit 8227c5b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fantasy_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ def __init__(

self.games = self._get_games()

self._get_team_owner()

self.draft_class = self._get_draft_class()

self.players = self._get_all_player_scoring()

self.logger.info(f"Fantasy stats init: Done")

def _get_team_owner(self):
self._team_owner_map = {}
for member in self.league.members:
id = member.get('id')
name = f"{member.get('firstName')} {member.get('lastName')}"
self._team_owner_map[id] = name

def _get_team_byes(self):
bye_week_map = {}
res = requests.get(
Expand Down Expand Up @@ -473,13 +482,14 @@ def get_league_overview(self):
team_info = []
team_info.append(f"{team.team_name} ({team.team_abbrev})")
team_info.append(team.standing)
team_info.append(team.playoff_pct)
team_info.append(f"{team.playoff_pct:.2f}")
team_info.append(team.division_name)
team_info.append(f"{team.wins}-{team.losses}-{team.ties}")
team_info.append(team.points_for)
team_info.append(team.points_against)
team_info.append(team.acquisitions)
team_info.append(team.owner)
owners = [self._team_owner_map[owner] for owner in team.owners]
team_info.append(", ".join(owners))
league_overview.extend([team_info])

df = pd.DataFrame(
Expand Down

0 comments on commit 8227c5b

Please sign in to comment.