Jon Solow
commited on
Commit
·
0045f00
1
Parent(s):
a42b348
Only map scores if game has started
Browse files- src/stats.py +25 -17
src/stats.py
CHANGED
@@ -325,26 +325,34 @@ def get_yahoo_schedule() -> dict[int, dict[str, dict[str, str | int | pd.Timesta
|
|
325 |
away_team = team_id_to_abbr[game["away_team_id"]]
|
326 |
home_team = team_id_to_abbr[game["home_team_id"]]
|
327 |
week = YAHOO_WEEK_MAP[int(game["week_number"])]
|
328 |
-
away_score = int(game["total_away_points"] or 0)
|
329 |
-
home_score = int(game["total_home_points"] or 0)
|
330 |
if week not in schedule_map:
|
331 |
schedule_map[week] = {}
|
332 |
|
333 |
-
home_team_map: dict[str, str | int | pd.Timestamp] = {
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
"
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
|
349 |
schedule_map[week][home_team] = home_team_map
|
350 |
schedule_map[week][away_team] = away_team_map
|
|
|
325 |
away_team = team_id_to_abbr[game["away_team_id"]]
|
326 |
home_team = team_id_to_abbr[game["home_team_id"]]
|
327 |
week = YAHOO_WEEK_MAP[int(game["week_number"])]
|
|
|
|
|
328 |
if week not in schedule_map:
|
329 |
schedule_map[week] = {}
|
330 |
|
331 |
+
home_team_map: dict[str, str | int | pd.Timestamp] = {}
|
332 |
+
away_team_map: dict[str, str | int | pd.Timestamp] = {}
|
333 |
+
|
334 |
+
if game["status_type"] != "pregame":
|
335 |
+
away_score = int(game["total_away_points"] or 0)
|
336 |
+
home_score = int(game["total_home_points"] or 0)
|
337 |
+
home_team_map.update(
|
338 |
+
{
|
339 |
+
"score": home_score,
|
340 |
+
"opponent_score": away_score,
|
341 |
+
}
|
342 |
+
)
|
343 |
+
away_team_map.update(
|
344 |
+
{
|
345 |
+
"score": away_score,
|
346 |
+
"opponent_score": home_score,
|
347 |
+
}
|
348 |
+
)
|
349 |
+
|
350 |
+
if game["status_type"] == "final":
|
351 |
+
home_team_win = home_score > away_score
|
352 |
+
home_status = "Win" if home_team_win else "Loss"
|
353 |
+
away_status = "Loss" if home_team_win else "Win"
|
354 |
+
home_team_map.update({"status": home_status})
|
355 |
+
away_team_map.update({"status": away_status})
|
356 |
|
357 |
schedule_map[week][home_team] = home_team_map
|
358 |
schedule_map[week][away_team] = away_team_map
|