Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 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 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
"home_hits",
|
| 948 |
-
"away_errors",
|
| 949 |
-
"home_errors",
|
| 950 |
-
]
|
| 951 |
)
|
| 952 |
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
and
|
| 956 |
-
and (is_live_candidate or (is_final_candidate and missing_boxscore))
|
| 957 |
)
|
| 958 |
|
| 959 |
-
if
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 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:
|