Syntrex commited on
Commit
5ada8b2
·
verified ·
1 Parent(s): 9bbdb16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -921,7 +921,7 @@ def enrich_live_games_from_feeds(scores_df: pd.DataFrame) -> pd.DataFrame:
921
  return scores_df
922
 
923
  rows = []
924
- feed_calls = 0
925
 
926
  for _, row in scores_df.iterrows():
927
  game = row.to_dict()
@@ -938,32 +938,29 @@ def enrich_live_games_from_feeds(scores_df: pd.DataFrame) -> pd.DataFrame:
938
  token in status for token in ["final", "game over", "completed", "ended"]
939
  )
940
 
941
- missing_boxscore = any(
942
- pd.isna(game.get(col)) or str(game.get(col)).strip().lower() in {"", "nan", "none"}
943
- for col in [
944
- "away_score",
945
- "home_score",
946
- "away_hits",
947
- "home_hits",
948
- "away_errors",
949
- "home_errors",
950
- ]
951
  )
952
 
953
- should_enrich = (
954
- game_pk.isdigit()
955
- and feed_calls < MAX_LIVE_FEEDS
956
- and (is_live_candidate or (is_final_candidate and missing_boxscore))
957
  )
958
 
959
- if should_enrich:
960
  try:
961
  feed = load_live_game_feed_cached(game_pk)
962
  if isinstance(feed, dict) and feed:
963
  game = enrich_game_from_live_feed(game, feed)
964
- feed_calls += 1
965
 
966
- # Preserve final status for completed games
 
 
 
967
  if is_final_candidate:
968
  game["status"] = original_status if original_status else "Final"
969
  except Exception:
 
921
  return scores_df
922
 
923
  rows = []
924
+ live_feed_calls = 0
925
 
926
  for _, row in scores_df.iterrows():
927
  game = row.to_dict()
 
938
  token in status for token in ["final", "game over", "completed", "ended"]
939
  )
940
 
941
+ # For finals, enrich aggressively if we have a usable game_pk.
942
+ # For live games, still respect the live feed cap.
943
+ should_enrich_live = (
944
+ is_live_candidate
945
+ and game_pk.isdigit()
946
+ and live_feed_calls < MAX_LIVE_FEEDS
 
 
 
 
947
  )
948
 
949
+ should_enrich_final = (
950
+ is_final_candidate
951
+ and game_pk.isdigit()
 
952
  )
953
 
954
+ if should_enrich_live or should_enrich_final:
955
  try:
956
  feed = load_live_game_feed_cached(game_pk)
957
  if isinstance(feed, dict) and feed:
958
  game = enrich_game_from_live_feed(game, feed)
 
959
 
960
+ if should_enrich_live:
961
+ live_feed_calls += 1
962
+
963
+ # Preserve original completed-game status text
964
  if is_final_candidate:
965
  game["status"] = original_status if original_status else "Final"
966
  except Exception: