Skip to content

Commit

Permalink
feat: Add active status to Player
Browse files Browse the repository at this point in the history
This uses the embedded stats objects to decipher whether a player was active in a historical week.
* `active`: the player had a game and participated in it
* `inactive`: the player had a game but did not participate in it (due to injury or suspension)
* `bye`: the player did not have a game that week
  • Loading branch information
DesiPilla committed Nov 18, 2023
1 parent 96b4e31 commit 3cda1f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions espn_api/football/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, data, year):
self.percent_owned = round(player.get('ownership', {}).get('percentOwned', -1), 2)
self.percent_started = round(player.get('ownership', {}).get('percentStarted', -1), 2)

self.active_status = 'bye'
player_stats = player.get('stats', [])
for stats in player_stats:
if stats.get('seasonId') != year:
Expand All @@ -49,5 +50,12 @@ def __init__(self, data, year):
self.avg_points = self.stats.get(0, {}).get('avg_points', 0)
self.projected_avg_points = self.stats.get(0, {}).get('projected_avg_points', 0)

if not stat_source:
if not self.stats[scoring_period][breakdown_type]:
self.active_status = 'inactive'
else:
self.active_status = 'active'


def __repr__(self):
return f'Player({self.name})'

0 comments on commit 3cda1f4

Please sign in to comment.