mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
Make sure sports displays are properly processing number of recent games to show
This commit is contained in:
@@ -1133,21 +1133,35 @@ class NCAAFBRecentManager(BaseNCAAFBManager): # Renamed class
|
||||
|
||||
# Filter for favorite teams
|
||||
if self.favorite_teams:
|
||||
team_games = [game for game in processed_games
|
||||
# Get all games involving favorite teams
|
||||
favorite_team_games = [game for game in processed_games
|
||||
if game['home_abbr'] in self.favorite_teams or
|
||||
game['away_abbr'] in self.favorite_teams]
|
||||
self.logger.info(f"[NCAAFB Recent] Found {favorite_games_found} favorite team games out of {len(processed_games)} total final games within last 21 days")
|
||||
|
||||
# Select one game per favorite team (most recent 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 most recent
|
||||
team_specific_games.sort(key=lambda g: g.get('start_time_utc') or datetime.min.replace(tzinfo=timezone.utc), reverse=True)
|
||||
team_games.append(team_specific_games[0])
|
||||
|
||||
# Sort the final list by game time (most recent first)
|
||||
team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.min.replace(tzinfo=timezone.utc), reverse=True)
|
||||
|
||||
# Debug: Show which games are selected for display
|
||||
for i, game in enumerate(team_games):
|
||||
self.logger.info(f"[NCAAFB Recent DEBUG] Game {i+1} for display: {game['away_abbr']} @ {game['home_abbr']} - {game.get('start_time_utc')} - Score: {game['away_score']}-{game['home_score']}")
|
||||
else:
|
||||
team_games = processed_games # Show all recent games if no favorites defined
|
||||
self.logger.info(f"[NCAAFB Recent] Found {len(processed_games)} total final games within last 21 days (no favorite teams configured)")
|
||||
|
||||
# Sort by game time, most recent first
|
||||
team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.min.replace(tzinfo=timezone.utc), reverse=True)
|
||||
|
||||
# Limit to the specified number of recent games
|
||||
team_games = team_games[:self.recent_games_to_show]
|
||||
|
||||
|
||||
@@ -893,15 +893,29 @@ class NFLRecentManager(BaseNFLManager): # Renamed class
|
||||
|
||||
# Filter for favorite teams only if the config is set
|
||||
if self.nfl_config.get("show_favorite_teams_only", False):
|
||||
team_games = [game for game in processed_games
|
||||
# Get all games involving favorite teams
|
||||
favorite_team_games = [game for game in processed_games
|
||||
if game['home_abbr'] in self.favorite_teams or
|
||||
game['away_abbr'] in self.favorite_teams]
|
||||
|
||||
# Select one game per favorite team (most recent 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 most recent
|
||||
team_specific_games.sort(key=lambda g: g.get('start_time_utc') or datetime.min.replace(tzinfo=self._get_timezone()), reverse=True)
|
||||
team_games.append(team_specific_games[0])
|
||||
|
||||
# Sort the final list by game time (most recent first)
|
||||
team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.min.replace(tzinfo=self._get_timezone()), reverse=True)
|
||||
else:
|
||||
team_games = processed_games # Show all recent games if no favorites defined
|
||||
|
||||
# Sort by game time, most recent first
|
||||
team_games.sort(key=lambda g: g.get('start_time_utc') or datetime.min.replace(tzinfo=self._get_timezone()), reverse=True)
|
||||
|
||||
# Limit to the specified number of recent games (default 5)
|
||||
recent_games_to_show = self.nfl_config.get("recent_games_to_show", 5)
|
||||
team_games = team_games[:recent_games_to_show]
|
||||
|
||||
Reference in New Issue
Block a user