From 6fcc93cab8a467362c5971d4620afe587cd4df31 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Wed, 17 Sep 2025 14:46:57 -0400 Subject: [PATCH] Fix ncaafb ranking display (#45) * Fix NCAAFB ranking display issue - Remove duplicate ranking system that was drawing rankings behind team logos - Old system (_get_rank) was drawing rankings at top of logos - New system (_fetch_team_rankings) correctly draws rankings in bottom corners - Remove old ranking calls from live, recent, and upcoming game drawing functions - Remove unnecessary _fetch_rankings() calls from update methods - Rankings now only appear in designated corner positions, not overlapping logos Fixes issue where team rankings/betting lines were being drawn behind team logos instead of replacing team records in the corners. * Add missing show_ranking and show_records options to NCAAFB web UI - Add show_ranking option to NCAAFB scoreboard config template - Add show_records and show_ranking toggle switches to NCAAFB web UI - Update JavaScript form collection to include new fields - Users can now control whether to show team records or rankings via web interface This completes the fix for NCAAFB ranking display - users can now enable show_ranking in the web UI to see AP Top 25 rankings instead of team records. --- config/config.template.json | 1 + src/ncaa_fb_managers.py | 64 ++----------------------------------- templates/index.html | 24 +++++++++++++- 3 files changed, 27 insertions(+), 62 deletions(-) diff --git a/config/config.template.json b/config/config.template.json index f2cb4e0d..388d8a77 100644 --- a/config/config.template.json +++ b/config/config.template.json @@ -305,6 +305,7 @@ ], "logo_dir": "assets/sports/ncaa_logos", "show_records": true, + "show_ranking": true, "display_modes": { "ncaa_fb_live": true, "ncaa_fb_recent": true, diff --git a/src/ncaa_fb_managers.py b/src/ncaa_fb_managers.py index 9baac1e8..0e82c24c 100644 --- a/src/ncaa_fb_managers.py +++ b/src/ncaa_fb_managers.py @@ -870,9 +870,6 @@ class NCAAFBLiveManager(BaseNCAAFBManager): # Renamed class self.logger.warning("[NCAAFB] Test mode: Could not parse clock") # Changed log prefix # No actual display call here, let main loop handle it else: - # Fetch rankings - self._fetch_rankings() - # Fetch live game data data = self._fetch_data() new_live_games = [] @@ -1000,23 +997,7 @@ class NCAAFBLiveManager(BaseNCAAFBManager): # Renamed class main_img.paste(away_logo, (away_x, away_y), away_logo) # --- Draw Text Elements on Overlay --- - # Ranking (if ranked) - home_rank = self._get_rank(game["home_abbr"]) - away_rank = self._get_rank(game["away_abbr"]) - - if home_rank > 0: - rank_text = str(home_rank) - rank_width = draw_overlay.textlength(rank_text, font=self.fonts['rank']) - rank_x = home_x - 8 - rank_y = 2 - self._draw_text_with_outline(draw_overlay, rank_text, (rank_x, rank_y), self.fonts['rank']) - - if away_rank > 0: - rank_text = str(away_rank) - rank_width = draw_overlay.textlength(rank_text, font=self.fonts['rank']) - rank_x = away_x + away_logo.width + 8 - rank_y = 2 - self._draw_text_with_outline(draw_overlay, rank_text, (rank_x, rank_y), self.fonts['rank']) + # Note: Rankings are now handled in the records/rankings section below # Scores (centered, slightly above bottom) home_score = str(game.get("home_score", "0")) @@ -1161,9 +1142,6 @@ class NCAAFBRecentManager(BaseNCAAFBManager): # Renamed class self.last_update = current_time # Update time even if fetch fails try: - # Fetch rankings - self._fetch_rankings() - data = self._fetch_data() # Uses shared cache if not data or 'events' not in data: self.logger.warning("[NCAAFB Recent] No events found in shared data.") # Changed log prefix @@ -1297,23 +1275,7 @@ class NCAAFBRecentManager(BaseNCAAFBManager): # Renamed class main_img.paste(away_logo, (away_x, away_y), away_logo) # Draw Text Elements on Overlay - # Ranking (if ranked) - home_rank = self._get_rank(game["home_abbr"]) - away_rank = self._get_rank(game["away_abbr"]) - - if home_rank > 0: - rank_text = str(home_rank) - rank_width = draw_overlay.textlength(rank_text, font=self.fonts['rank']) - rank_x = home_x - 8 - rank_y = 2 - self._draw_text_with_outline(draw_overlay, rank_text, (rank_x, rank_y), self.fonts['rank']) - - if away_rank > 0: - rank_text = str(away_rank) - rank_width = draw_overlay.textlength(rank_text, font=self.fonts['rank']) - rank_x = away_x + away_logo.width - 8 - rank_y = 2 - self._draw_text_with_outline(draw_overlay, rank_text, (rank_x, rank_y), self.fonts['rank']) + # Note: Rankings are now handled in the records/rankings section below # Final Scores (Centered, same position as live) home_score = str(game.get("home_score", "0")) @@ -1479,9 +1441,6 @@ class NCAAFBUpcomingManager(BaseNCAAFBManager): # Renamed class self.last_update = current_time try: - # Fetch rankings - self._fetch_rankings() - data = self._fetch_data() # Uses shared cache if not data or 'events' not in data: self.logger.warning("[NCAAFB Upcoming] No events found in shared data.") # Changed log prefix @@ -1669,24 +1628,7 @@ class NCAAFBUpcomingManager(BaseNCAAFBManager): # Renamed class game_date = game.get("game_date", "") game_time = game.get("game_time", "") - # Ranking (if ranked) - home_rank = self._get_rank(game["home_abbr"]) - away_rank = self._get_rank(game["away_abbr"]) - - if home_rank > 0: - rank_text = str(home_rank) - rank_width = draw_overlay.textlength(rank_text, font=self.fonts['rank']) - rank_x = home_x - 8 - rank_y = 2 - self._draw_text_with_outline(draw_overlay, rank_text, (rank_x, rank_y), self.fonts['rank']) - - if away_rank > 0: - rank_text = str(away_rank) - rank_width = draw_overlay.textlength(rank_text, font=self.fonts['rank']) - rank_x = away_x + away_logo.width - 8 - rank_y = 2 - self._draw_text_with_outline(draw_overlay, rank_text, (rank_x, rank_y), self.fonts['rank']) - + # Note: Rankings are now handled in the records/rankings section below # "Next Game" at the top (use smaller status font) status_text = "Next Game" diff --git a/templates/index.html b/templates/index.html index 59e3445b..6520006b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1277,6 +1277,26 @@