Skip to content

Commit

Permalink
Bug fix: missing games
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Crom authored and Benjamin Crom committed Apr 5, 2018
1 parent f0e7165 commit 3505d30
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
16 changes: 12 additions & 4 deletions baseball/baseball.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,24 @@ def get_svg_str(self):
return get_game_svg_str(self)

def set_gametimes(self):
self.start_datetime = (
self.inning_list[0].top_half_appearance_list[0].start_datetime
)
if self.inning_list[0].top_half_appearance_list:
self.start_datetime = (
self.inning_list[0].top_half_appearance_list[0].start_datetime
)
else:
self.start_datetime = None

last_inning_half_appearance_list = (
self.inning_list[0].bottom_half_appearance_list or
self.inning_list[0].top_half_appearance_list
)

self.end_datetime = last_inning_half_appearance_list[-1].end_datetime
if last_inning_half_appearance_list:
self.end_datetime = (
last_inning_half_appearance_list[-1].end_datetime
)
else:
self.end_datetime = None

if self.start_datetime:
self.start_str = self.start_datetime.astimezone(
Expand Down
11 changes: 8 additions & 3 deletions baseball/fetch_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,14 @@ def get_game_from_xml_strings(boxscore_raw_xml, players_raw_xml, inning_raw_xml)
boxscore_xml_obj = fromstring(boxscore_raw_xml)
players_xml_obj = fromstring(players_raw_xml)
inning_xml_obj = fromstring(inning_raw_xml)
this_game = get_game_obj(boxscore_xml_obj,
players_xml_obj,
inning_xml_obj)
if (boxscore_xml_obj.tag == 'Error' or
players_xml_obj.tag == 'Error' or
inning_xml_obj.tag == 'Error'):
this_game = None
else:
this_game = get_game_obj(boxscore_xml_obj,
players_xml_obj,
inning_xml_obj)
else:
this_game = None

Expand Down
4 changes: 2 additions & 2 deletions baseball/generate_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1994,8 +1994,8 @@ def get_game_title_str(game):
def assemble_game_title_svg(game):
game_title_svg = ''
game_str = '{} @ {}'.format(game.away_team.name, game.home_team.name)
if game.first_pitch_str and game.last_pitch_str:
game_datetime = '{}{}'.format(game.first_pitch_str, game.last_pitch_str)
if game.start_str and game.end_str:
game_datetime = '{}{}'.format(game.start_str, game.end_str)
else:
game_datetime = game.game_date_str

Expand Down

0 comments on commit 3505d30

Please sign in to comment.