Skip to content

Commit c4788cb

Browse files
authored
Merge pull request #21 from cuappdev/skye/launch-fixes
2 parents 6394540 + 701b658 commit c4788cb

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/scrapers/games_scraper.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ def process_game_data(game_data):
188188
# ISO format
189189
utc_date_str = game_data["utc_date"].isoformat() if game_data["utc_date"] else None
190190

191+
game_time = game_data["time"]
192+
if game_time is None:
193+
game_time = "TBD"
194+
191195
curr_game = GameService.get_game_by_data(
192196
city,
193197
game_data["date"],
@@ -196,7 +200,7 @@ def process_game_data(game_data):
196200
team.id,
197201
game_data["sport"],
198202
state,
199-
game_data["time"],
203+
game_time,
200204
)
201205
if curr_game:
202206
if curr_game.result != game_data["result"]:
@@ -207,7 +211,22 @@ def process_game_data(game_data):
207211
if utc_date_str:
208212
GameService.update_game(curr_game.id, {"utc_date": utc_date_str})
209213
return
210-
214+
# if game time is not TBD, check for existing game with TBD time to update
215+
if game_time != "TBD":
216+
curr_game = GameService.get_game_by_data(
217+
city,
218+
game_data["date"],
219+
game_data["gender"],
220+
location,
221+
team.id,
222+
game_data["sport"],
223+
state,
224+
"TBD",
225+
)
226+
if curr_game:
227+
GameService.update_game(curr_game.id, {"time": game_time})
228+
GameService.update_game(curr_game.id, {"utc_date": utc_date_str})
229+
return
211230
game_data = {
212231
"city": city,
213232
"date": game_data["date"],
@@ -217,7 +236,7 @@ def process_game_data(game_data):
217236
"result": game_data["result"],
218237
"sport": game_data["sport"],
219238
"state": state,
220-
"time": game_data["time"],
239+
"time": game_time,
221240
"box_score": game_data["box_score"],
222241
"score_breakdown": game_data["score_breakdown"],
223242
"utc_date": utc_date_str

0 commit comments

Comments
 (0)