fix upcoming game logic

This commit is contained in:
Chuck
2025-09-15 18:22:25 -04:00
parent d78c592d6a
commit 91211d5c86

View File

@@ -1449,17 +1449,31 @@ class NCAAFBUpcomingManager(BaseNCAAFBManager): # Renamed class
# Filter for favorite teams only if the config is set # Filter for favorite teams only if the config is set
if self.ncaa_fb_config.get("show_favorite_teams_only", False): if self.ncaa_fb_config.get("show_favorite_teams_only", False):
team_games = [game for game in processed_games # Get all games involving favorite teams
if game['home_abbr'] in self.favorite_teams or favorite_team_games = [game for game in processed_games
game['away_abbr'] in self.favorite_teams] if game['home_abbr'] in self.favorite_teams or
game['away_abbr'] in self.favorite_teams]
# Select one game per favorite team (earliest upcoming game for each team)
team_games = []
for team in self.favorite_teams:
# Find games where this team is playing
team_specific_games = [game for game in favorite_team_games
if game['home_abbr'] == team or game['away_abbr'] == team]
if team_specific_games:
# Sort by game time and take the earliest
team_specific_games.sort(key=lambda g: g.get('start_time_utc') or datetime.max.replace(tzinfo=timezone.utc))
team_games.append(team_specific_games[0])
# Sort the final list by game time
team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.max.replace(tzinfo=timezone.utc))
else: else:
team_games = processed_games # Show all upcoming if no favorites team_games = processed_games # Show all upcoming if no favorites
# Sort by game time, earliest first
# Sort by game time, earliest first team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.max.replace(tzinfo=timezone.utc))
team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.max.replace(tzinfo=timezone.utc)) # Limit to the specified number of upcoming games
team_games = team_games[:self.upcoming_games_to_show]
# Limit to the specified number of upcoming games
team_games = team_games[:self.upcoming_games_to_show]
# Log changes or periodically # Log changes or periodically
should_log = ( should_log = (