Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix/Fix multiple pro schedule requests #631

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions espn_api/basketball/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

def _fetch_teams(self, data):
'''Fetch teams in league'''
pro_schedule = self._get_all_pro_schedule()
super()._fetch_teams(data, TeamClass=Team, pro_schedule=pro_schedule)
self.pro_schedule = self._get_all_pro_schedule()
super()._fetch_teams(data, TeamClass=Team, pro_schedule=self.pro_schedule)

# replace opponentIds in schedule with team instances
for team in self.teams:
Expand Down Expand Up @@ -184,8 +184,7 @@
data = self.espn_request.league_get(params=params, headers=headers)

schedule = data['schedule']
pro_schedule = self._get_all_pro_schedule()
box_data = [self.BoxScoreClass(matchup, pro_schedule, matchup_total, self.year, scoring_id) for matchup in schedule]
box_data = [self.BoxScoreClass(matchup, self.pro_schedule, matchup_total, self.year, scoring_id) for matchup in schedule]

for team in self.teams:
for matchup in box_data:
Expand All @@ -207,14 +206,12 @@

data = self.espn_request.get_player_card(playerId, self.finalScoringPeriod)

pro_schedule = self._get_all_pro_schedule()

if include_news:
news = {}
for id in playerId:
news[id] = self.espn_request.get_player_news(id)

if len(data['players']) == 1:
return Player(data['players'][0], self.year, pro_schedule, news=news.get(playerId[0], []) if include_news else None)
return Player(data['players'][0], self.year, self.pro_schedule, news=news.get(playerId[0], []) if include_news else None)
if len(data['players']) > 1:
return [Player(player, self.year, pro_schedule, news=news.get(player['id'], []) if include_news else None) for player in data['players']]
return [Player(player, self.year, self.pro_schedule, news=news.get(player['id'], []) if include_news else None) for player in data['players']]

Check warning on line 217 in espn_api/basketball/league.py

View check run for this annotation

Codecov / codecov/patch

espn_api/basketball/league.py#L217

Added line #L217 was not covered by tests