From 1d6fef51aba73b185c7a0d5e3e23c1be387dd44f Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Tue, 2 Dec 2025 16:12:16 -0600 Subject: [PATCH] Consolidate season config variables to single source (v2.21.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove redundant sba_current_season and pd_current_season config values. All code now uses sba_season and pd_season, which properly read from environment variables. Fixes /team command defaulting to Season 12. - Remove duplicate *_current_season constants from config.py - Update 100+ references across commands, services, and utils - sba_season defaults to 13, pd_season defaults to 10 - Environment variables SBA_SEASON/PD_SEASON now work correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- VERSION | 2 +- commands/admin/management.py | 2 +- commands/draft/admin.py | 4 ++-- commands/draft/board.py | 2 +- commands/draft/list.py | 26 ++++++++++++------------ commands/draft/picks.py | 8 ++++---- commands/draft/status.py | 8 ++++---- commands/examples/enhanced_player.py | 8 ++++---- commands/examples/migration_example.py | 4 ++-- commands/league/schedule.py | 4 ++-- commands/league/standings.py | 4 ++-- commands/players/info.py | 4 ++-- commands/profile/images.py | 4 ++-- commands/teams/branding.py | 4 +++- commands/teams/info.py | 4 ++-- commands/teams/roster.py | 2 +- commands/transactions/dropadd.py | 2 +- commands/transactions/ilmove.py | 2 +- commands/transactions/management.py | 28 +++++++++++++------------- commands/transactions/trade.py | 4 ++-- commands/voice/channels.py | 4 ++-- config.py | 7 ++----- services/draft_service.py | 2 +- services/league_service.py | 6 +++--- services/player_service.py | 2 +- services/team_service.py | 6 +++--- services/trade_builder.py | 2 +- services/transaction_builder.py | 2 +- tasks/draft_monitor.py | 6 +++--- test_real_data.py | 10 ++++----- tests/test_services_team_service.py | 8 ++++---- utils/autocomplete.py | 6 +++--- utils/permissions.py | 2 +- utils/team_utils.py | 6 +++--- views/embeds.py | 8 ++++---- 35 files changed, 101 insertions(+), 102 deletions(-) diff --git a/VERSION b/VERSION index 7329e21..db65e21 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.20.0 +2.21.0 diff --git a/commands/admin/management.py b/commands/admin/management.py index 243341b..5377ca7 100644 --- a/commands/admin/management.py +++ b/commands/admin/management.py @@ -85,7 +85,7 @@ class AdminCommands(commands.Cog): name="Bot Information", value=f"**Latency:** {round(self.bot.latency * 1000)}ms\n" f"**Version:** Discord.py {discord.__version__}\n" - f"**Current Season:** {get_config().sba_current_season}", + f"**Current Season:** {get_config().sba_season}", inline=True ) diff --git a/commands/draft/admin.py b/commands/draft/admin.py index 17d3af7..bb87170 100644 --- a/commands/draft/admin.py +++ b/commands/draft/admin.py @@ -49,7 +49,7 @@ class DraftAdminGroup(app_commands.Group): # Get current pick config = get_config() current_pick = await draft_pick_service.get_pick( - config.sba_current_season, + config.sba_season, draft_data.currentpick ) @@ -142,7 +142,7 @@ class DraftAdminGroup(app_commands.Group): return # Verify pick exists - pick = await draft_pick_service.get_pick(config.sba_current_season, pick_number) + pick = await draft_pick_service.get_pick(config.sba_season, pick_number) if not pick: embed = EmbedTemplate.error( "Pick Not Found", diff --git a/commands/draft/board.py b/commands/draft/board.py index a40ea37..f89421d 100644 --- a/commands/draft/board.py +++ b/commands/draft/board.py @@ -58,7 +58,7 @@ class DraftBoardCommands(commands.Cog): # Get picks for this round picks = await draft_pick_service.get_picks_by_round( - config.sba_current_season, + config.sba_season, round_number, include_taken=True ) diff --git a/commands/draft/list.py b/commands/draft/list.py index afe9fb6..3a70110 100644 --- a/commands/draft/list.py +++ b/commands/draft/list.py @@ -33,7 +33,7 @@ async def fa_player_autocomplete( players = await player_service.search_players( current, limit=25, - season=config.sba_current_season + season=config.sba_season ) # Filter to FA team @@ -74,7 +74,7 @@ class DraftListCommands(commands.Cog): # Get user's team team = await team_service.get_team_by_owner( interaction.user.id, - config.sba_current_season + config.sba_season ) if not team: @@ -87,7 +87,7 @@ class DraftListCommands(commands.Cog): # Get draft list draft_list = await draft_list_service.get_team_list( - config.sba_current_season, + config.sba_season, team.id ) @@ -121,7 +121,7 @@ class DraftListCommands(commands.Cog): # Get user's team team = await team_service.get_team_by_owner( interaction.user.id, - config.sba_current_season + config.sba_season ) if not team: @@ -133,7 +133,7 @@ class DraftListCommands(commands.Cog): return # Get player - players = await player_service.get_players_by_name(player, config.sba_current_season) + players = await player_service.get_players_by_name(player, config.sba_season) if not players: embed = EmbedTemplate.error( "Player Not Found", @@ -155,7 +155,7 @@ class DraftListCommands(commands.Cog): # Check if player already in list current_list = await draft_list_service.get_team_list( - config.sba_current_season, + config.sba_season, team.id ) @@ -179,7 +179,7 @@ class DraftListCommands(commands.Cog): # Add to list updated_list = await draft_list_service.add_to_list( - config.sba_current_season, + config.sba_season, team.id, player_obj.id, rank @@ -228,7 +228,7 @@ class DraftListCommands(commands.Cog): # Get user's team team = await team_service.get_team_by_owner( interaction.user.id, - config.sba_current_season + config.sba_season ) if not team: @@ -240,7 +240,7 @@ class DraftListCommands(commands.Cog): return # Get player - players = await player_service.get_players_by_name(player, config.sba_current_season) + players = await player_service.get_players_by_name(player, config.sba_season) if not players: embed = EmbedTemplate.error( "Player Not Found", @@ -253,7 +253,7 @@ class DraftListCommands(commands.Cog): # Remove from list success = await draft_list_service.remove_player_from_list( - config.sba_current_season, + config.sba_season, team.id, player_obj.id ) @@ -287,7 +287,7 @@ class DraftListCommands(commands.Cog): # Get user's team team = await team_service.get_team_by_owner( interaction.user.id, - config.sba_current_season + config.sba_season ) if not team: @@ -300,7 +300,7 @@ class DraftListCommands(commands.Cog): # Get current list size current_list = await draft_list_service.get_team_list( - config.sba_current_season, + config.sba_season, team.id ) @@ -314,7 +314,7 @@ class DraftListCommands(commands.Cog): # Clear list success = await draft_list_service.clear_list( - config.sba_current_season, + config.sba_season, team.id ) diff --git a/commands/draft/picks.py b/commands/draft/picks.py index cf39cd1..837d272 100644 --- a/commands/draft/picks.py +++ b/commands/draft/picks.py @@ -40,7 +40,7 @@ async def fa_player_autocomplete( players = await player_service.search_players( current, limit=25, - season=config.sba_current_season + season=config.sba_season ) # Filter to FA team @@ -138,7 +138,7 @@ class DraftPicksCog(commands.Cog): # Get user's team (CACHED via @cached_single_item) team = await team_service.get_team_by_owner( interaction.user.id, - config.sba_current_season + config.sba_season ) if not team: @@ -161,7 +161,7 @@ class DraftPicksCog(commands.Cog): # Get current pick current_pick = await draft_pick_service.get_pick( - config.sba_current_season, + config.sba_season, draft_data.currentpick ) @@ -184,7 +184,7 @@ class DraftPicksCog(commands.Cog): return # Get player - players = await player_service.get_players_by_name(player_name, config.sba_current_season) + players = await player_service.get_players_by_name(player_name, config.sba_season) if not players: embed = await create_pick_illegal_embed( diff --git a/commands/draft/status.py b/commands/draft/status.py index 9478379..de83105 100644 --- a/commands/draft/status.py +++ b/commands/draft/status.py @@ -47,7 +47,7 @@ class DraftStatusCommands(commands.Cog): # Get current pick current_pick = await draft_pick_service.get_pick( - config.sba_current_season, + config.sba_season, draft_data.currentpick ) @@ -99,7 +99,7 @@ class DraftStatusCommands(commands.Cog): # Get current pick current_pick = await draft_pick_service.get_pick( - config.sba_current_season, + config.sba_season, draft_data.currentpick ) @@ -113,14 +113,14 @@ class DraftStatusCommands(commands.Cog): # Get recent picks recent_picks = await draft_pick_service.get_recent_picks( - config.sba_current_season, + config.sba_season, draft_data.currentpick, limit=5 ) # Get upcoming picks upcoming_picks = await draft_pick_service.get_upcoming_picks( - config.sba_current_season, + config.sba_season, draft_data.currentpick, limit=5 ) diff --git a/commands/examples/enhanced_player.py b/commands/examples/enhanced_player.py index 71be33f..f1568c8 100644 --- a/commands/examples/enhanced_player.py +++ b/commands/examples/enhanced_player.py @@ -71,7 +71,7 @@ class EnhancedPlayerCommands(commands.Cog): return # Use current season if not specified - search_season = season or get_config().sba_current_season + search_season = season or get_config().sba_season # Search for players players = await player_service.get_players_by_name(name, search_season) @@ -342,7 +342,7 @@ class EnhancedPlayerCommands(commands.Cog): # Perform search based on criteria players = await player_service.get_players_by_name( search_criteria['name'], - search_criteria['season'] or get_config().sba_current_season + search_criteria['season'] or get_config().sba_season ) if players: @@ -351,13 +351,13 @@ class EnhancedPlayerCommands(commands.Cog): await self._show_player_details( interaction, players[0], - search_criteria['season'] or get_config().sba_current_season + search_criteria['season'] or get_config().sba_season ) else: await self._show_player_selection( interaction, players, - search_criteria['season'] or get_config().sba_current_season + search_criteria['season'] or get_config().sba_season ) else: embed = EmbedTemplate.warning( diff --git a/commands/examples/migration_example.py b/commands/examples/migration_example.py index a0c0a45..e4dd923 100644 --- a/commands/examples/migration_example.py +++ b/commands/examples/migration_example.py @@ -48,7 +48,7 @@ class MigrationExampleCommands(commands.Cog): """Old style team listing - basic embed only.""" await interaction.response.defer() - season = season or get_config().sba_current_season + season = season or get_config().sba_season teams = await team_service.get_teams_by_season(season) if not teams: @@ -91,7 +91,7 @@ class MigrationExampleCommands(commands.Cog): """New style team listing - interactive with pagination and selection.""" await interaction.response.defer() - season = season or get_config().sba_current_season + season = season or get_config().sba_season teams = await team_service.get_teams_by_season(season) if not teams: diff --git a/commands/league/schedule.py b/commands/league/schedule.py index f8fbc2b..26dd224 100644 --- a/commands/league/schedule.py +++ b/commands/league/schedule.py @@ -45,7 +45,7 @@ class ScheduleCommands(commands.Cog): """Display game schedule for a week or team.""" await interaction.response.defer() - search_season = season or get_config().sba_current_season + search_season = season or get_config().sba_season if team: # Show team schedule @@ -75,7 +75,7 @@ class ScheduleCommands(commands.Cog): # """Display recent game results.""" # await interaction.response.defer() - # search_season = season or get_config().sba_current_season + # search_season = season or get_config().sba_season # if week: # # Show specific week results diff --git a/commands/league/standings.py b/commands/league/standings.py index 4fe381f..799b3f1 100644 --- a/commands/league/standings.py +++ b/commands/league/standings.py @@ -43,7 +43,7 @@ class StandingsCommands(commands.Cog): """Display league standings by division.""" await interaction.response.defer() - search_season = season or get_config().sba_current_season + search_season = season or get_config().sba_season if division: # Show specific division @@ -69,7 +69,7 @@ class StandingsCommands(commands.Cog): """Display playoff picture with division leaders and wild card race.""" await interaction.response.defer() - search_season = season or get_config().sba_current_season + search_season = season or get_config().sba_season self.logger.debug("Fetching playoff picture", season=search_season) playoff_data = await standings_service.get_playoff_picture(search_season) diff --git a/commands/players/info.py b/commands/players/info.py index 9f2afbf..b282cf3 100644 --- a/commands/players/info.py +++ b/commands/players/info.py @@ -27,7 +27,7 @@ async def player_name_autocomplete( try: # Use the dedicated search endpoint to get matching players - players = await player_service.search_players(current, limit=25, season=get_config().sba_current_season) + players = await player_service.search_players(current, limit=25, season=get_config().sba_season) # Convert to discord choices, limiting to 25 (Discord's max) choices = [] @@ -78,7 +78,7 @@ class PlayerInfoCommands(commands.Cog): self.logger.debug("Response deferred") # Search for player by name (use season parameter or default to current) - search_season = season or get_config().sba_current_season + search_season = season or get_config().sba_season self.logger.debug("Starting player search", api_call="get_players_by_name", season=search_season) players = await player_service.get_players_by_name(name, search_season) self.logger.info("Player search completed", players_found=len(players), season=search_season) diff --git a/commands/profile/images.py b/commands/profile/images.py index 87f98aa..902a518 100644 --- a/commands/profile/images.py +++ b/commands/profile/images.py @@ -279,7 +279,7 @@ class ImageCommands(commands.Cog): # Step 3: Find player self.logger.debug("Searching for player", player_name=player_name) - players = await player_service.get_players_by_name(player_name, get_config().sba_current_season) + players = await player_service.get_players_by_name(player_name, get_config().sba_season) if not players: self.logger.warning("Player not found", player_name=player_name) @@ -316,7 +316,7 @@ class ImageCommands(commands.Cog): # Step 4: Check permissions has_permission, permission_error = await can_edit_player_image( - interaction, player, get_config().sba_current_season, self.logger + interaction, player, get_config().sba_season, self.logger ) if not has_permission: diff --git a/commands/teams/branding.py b/commands/teams/branding.py index 720396f..05da7a4 100644 --- a/commands/teams/branding.py +++ b/commands/teams/branding.py @@ -17,6 +17,7 @@ from services import team_service from models.team import Team from utils.logging import get_contextual_logger from utils.decorators import logged_command +from utils.permissions import league_only from views.embeds import EmbedTemplate, EmbedColors from views.confirmations import ConfirmationView @@ -217,6 +218,7 @@ class BrandingCommands(commands.Cog): self.logger.info("BrandingCommands cog initialized") @app_commands.command(name="branding", description="Update your team's colors and logos") + @league_only() @logged_command("/branding") async def team_branding(self, interaction: discord.Interaction): """ @@ -229,7 +231,7 @@ class BrandingCommands(commands.Cog): """ # Get current season config = get_config() - season = config.sba_current_season + season = config.sba_season # Verify user owns a team (must do this BEFORE responding to interaction) ml_team = await team_service.get_team_by_owner(interaction.user.id, season) diff --git a/commands/teams/info.py b/commands/teams/info.py index 1c0a97d..ab0b457 100644 --- a/commands/teams/info.py +++ b/commands/teams/info.py @@ -36,7 +36,7 @@ class TeamInfoCommands(commands.Cog): await interaction.response.defer() # Use current season if not specified - season = season or get_config().sba_current_season + season = season or get_config().sba_season # Get team by abbreviation team = await team_service.get_team_by_abbrev(abbrev, season) @@ -67,7 +67,7 @@ class TeamInfoCommands(commands.Cog): """List all teams in a season.""" await interaction.response.defer() - season = season or get_config().sba_current_season + season = season or get_config().sba_season teams = await team_service.get_teams_by_season(season) diff --git a/commands/teams/roster.py b/commands/teams/roster.py index f8b90fc..ce7b7e3 100644 --- a/commands/teams/roster.py +++ b/commands/teams/roster.py @@ -43,7 +43,7 @@ class TeamRosterCommands(commands.Cog): await interaction.response.defer() # Get team by abbreviation - team = await team_service.get_team_by_abbrev(abbrev, get_config().sba_current_season) + team = await team_service.get_team_by_abbrev(abbrev, get_config().sba_season) if team is None: self.logger.info("Team not found", team_abbrev=abbrev) diff --git a/commands/transactions/dropadd.py b/commands/transactions/dropadd.py index f012852..23b8f2a 100644 --- a/commands/transactions/dropadd.py +++ b/commands/transactions/dropadd.py @@ -129,7 +129,7 @@ class DropAddCommands(commands.Cog): """ try: # Find player using the new search endpoint - players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season) + players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season) if not players: self.logger.error(f"Player not found: {player_name}") return False, f"Player '{player_name}' not found" diff --git a/commands/transactions/ilmove.py b/commands/transactions/ilmove.py index d994e5d..29cf211 100644 --- a/commands/transactions/ilmove.py +++ b/commands/transactions/ilmove.py @@ -134,7 +134,7 @@ class ILMoveCommands(commands.Cog): """ try: # Find player using the new search endpoint - players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season) + players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season) if not players: self.logger.error(f"Player not found: {player_name}") return False, f"Player '{player_name}' not found" diff --git a/commands/transactions/management.py b/commands/transactions/management.py index fb21a2c..ccf3fee 100644 --- a/commands/transactions/management.py +++ b/commands/transactions/management.py @@ -124,7 +124,7 @@ class TransactionCommands(commands.Cog): await interaction.response.defer() # Get user's team - team = await get_user_major_league_team(interaction.user.id, get_config().sba_current_season) + team = await get_user_major_league_team(interaction.user.id, get_config().sba_season) if not team: await interaction.followup.send( @@ -134,9 +134,9 @@ class TransactionCommands(commands.Cog): return # Get transactions in parallel - pending_task = transaction_service.get_pending_transactions(team.abbrev, get_config().sba_current_season) - frozen_task = transaction_service.get_frozen_transactions(team.abbrev, get_config().sba_current_season) - processed_task = transaction_service.get_processed_transactions(team.abbrev, get_config().sba_current_season) + pending_task = transaction_service.get_pending_transactions(team.abbrev, get_config().sba_season) + frozen_task = transaction_service.get_frozen_transactions(team.abbrev, get_config().sba_season) + processed_task = transaction_service.get_processed_transactions(team.abbrev, get_config().sba_season) pending_transactions = await pending_task frozen_transactions = await frozen_task @@ -147,7 +147,7 @@ class TransactionCommands(commands.Cog): if show_cancelled: cancelled_transactions = await transaction_service.get_team_transactions( team.abbrev, - get_config().sba_current_season, + get_config().sba_season, cancelled=True ) @@ -200,16 +200,16 @@ class TransactionCommands(commands.Cog): # Get target team if team: - target_team = await team_service.get_team_by_abbrev(team.upper(), get_config().sba_current_season) + target_team = await team_service.get_team_by_abbrev(team.upper(), get_config().sba_season) if not target_team: await interaction.followup.send( - f"❌ Could not find team '{team}' in season {get_config().sba_current_season}.", + f"❌ Could not find team '{team}' in season {get_config().sba_season}.", ephemeral=True ) return else: # Get user's team - user_teams = await team_service.get_teams_by_owner(interaction.user.id, get_config().sba_current_season) + user_teams = await team_service.get_teams_by_owner(interaction.user.id, get_config().sba_season) if not user_teams: await interaction.followup.send( "❌ You don't appear to own a team. Please specify a team abbreviation.", @@ -286,7 +286,7 @@ class TransactionCommands(commands.Cog): embed = EmbedTemplate.create_base_embed( title=f"📋 Transaction Status - {team.abbrev}", - description=f"{team.lname} • Season {get_config().sba_current_season}", + description=f"{team.lname} • Season {get_config().sba_season}", color=EmbedColors.INFO ) @@ -323,7 +323,7 @@ class TransactionCommands(commands.Cog): # No pending transactions - create single page embed = EmbedTemplate.create_base_embed( title=f"📋 Transaction Status - {team.abbrev}", - description=f"{team.lname} • Season {get_config().sba_current_season}", + description=f"{team.lname} • Season {get_config().sba_season}", color=EmbedColors.INFO ) @@ -353,7 +353,7 @@ class TransactionCommands(commands.Cog): if frozen_transactions: embed = EmbedTemplate.create_base_embed( title=f"📋 Transaction Status - {team.abbrev}", - description=f"{team.lname} • Season {get_config().sba_current_season}", + description=f"{team.lname} • Season {get_config().sba_season}", color=EmbedColors.INFO ) @@ -374,7 +374,7 @@ class TransactionCommands(commands.Cog): if processed_transactions: embed = EmbedTemplate.create_base_embed( title=f"📋 Transaction Status - {team.abbrev}", - description=f"{team.lname} • Season {get_config().sba_current_season}", + description=f"{team.lname} • Season {get_config().sba_season}", color=EmbedColors.INFO ) @@ -395,7 +395,7 @@ class TransactionCommands(commands.Cog): if cancelled_transactions: embed = EmbedTemplate.create_base_embed( title=f"📋 Transaction Status - {team.abbrev}", - description=f"{team.lname} • Season {get_config().sba_current_season}", + description=f"{team.lname} • Season {get_config().sba_season}", color=EmbedColors.INFO ) @@ -440,7 +440,7 @@ class TransactionCommands(commands.Cog): embed = EmbedTemplate.create_base_embed( title=f"{status_emoji} Roster Check - {team.abbrev}", - description=f"{team.lname} • Season {get_config().sba_current_season}", + description=f"{team.lname} • Season {get_config().sba_season}", color=embed_color ) diff --git a/commands/transactions/trade.py b/commands/transactions/trade.py index 0dea66e..ec29c55 100644 --- a/commands/transactions/trade.py +++ b/commands/transactions/trade.py @@ -282,7 +282,7 @@ class TradeCommands(commands.Cog): return # Find the player - players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season) + players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season) if not players: await interaction.followup.send( f"❌ Player '{player_name}' not found.", @@ -392,7 +392,7 @@ class TradeCommands(commands.Cog): return # Find the player - players = await player_service.search_players(player_name, limit=10, season=get_config().sba_current_season) + players = await player_service.search_players(player_name, limit=10, season=get_config().sba_season) if not players: await interaction.followup.send( f"❌ Player '{player_name}' not found.", diff --git a/commands/voice/channels.py b/commands/voice/channels.py index 9fc6e73..1efc5f3 100644 --- a/commands/voice/channels.py +++ b/commands/voice/channels.py @@ -61,7 +61,7 @@ class VoiceChannelCommands(commands.Cog): Returns: Team object or None if not found """ - season = season or get_config().sba_current_season + season = season or get_config().sba_season teams = await team_service.get_teams_by_owner(user_id, season) return teams[0] if teams else None @@ -76,7 +76,7 @@ class VoiceChannelCommands(commands.Cog): Returns: Major League Team object or None if not found """ - season = season or get_config().sba_current_season + season = season or get_config().sba_season teams = await team_service.get_teams_by_owner(user_id, season) # Filter to only Major League teams (3-character abbreviations) diff --git a/config.py b/config.py index 74603c9..2f7c024 100644 --- a/config.py +++ b/config.py @@ -26,8 +26,8 @@ class BotConfig(BaseSettings): discord_embed_description_limit: int = 4096 # League settings - sba_season: int = 12 - pd_season: int = 9 + sba_season: int = 13 + pd_season: int = 10 fa_lock_week: int = 14 sba_color: str = "a6ce39" weeks_per_season: int = 18 @@ -39,9 +39,6 @@ class BotConfig(BaseSettings): modern_stats_start_season: int = 8 offseason_flag: bool = False # When True, relaxes roster limits and disables weekly freeze/thaw - # Current Season Constants - sba_current_season: int = 12 - pd_current_season: int = 9 # API Constants api_version: str = "v3" diff --git a/services/draft_service.py b/services/draft_service.py index 1e1b4f9..d47f23a 100644 --- a/services/draft_service.py +++ b/services/draft_service.py @@ -169,7 +169,7 @@ class DraftService(BaseService[DraftData]): from config import get_config config = get_config() - season = config.sba_current_season + season = config.sba_season total_picks = config.draft_total_picks # Start with next pick diff --git a/services/league_service.py b/services/league_service.py index d39444c..49c96e5 100644 --- a/services/league_service.py +++ b/services/league_service.py @@ -113,7 +113,7 @@ class LeagueService(BaseService[Current]): List of standings data or None if not available """ try: - season = season or get_config().sba_current_season + season = season or get_config().sba_season client = await self.get_client() data = await client.get('standings', params=[('season', str(season))]) @@ -146,7 +146,7 @@ class LeagueService(BaseService[Current]): List of division standings or None if not available """ try: - season = season or get_config().sba_current_season + season = season or get_config().sba_season client = await self.get_client() data = await client.get(f'standings/division/{division_id}', params=[('season', str(season))]) @@ -174,7 +174,7 @@ class LeagueService(BaseService[Current]): List of league leaders or None if not available """ try: - season = season or get_config().sba_current_season + season = season or get_config().sba_season client = await self.get_client() params = [ diff --git a/services/player_service.py b/services/player_service.py index 14b93cb..569047a 100644 --- a/services/player_service.py +++ b/services/player_service.py @@ -192,7 +192,7 @@ class PlayerService(BaseService[Player]): """ try: if season is None: - season = get_config().sba_current_season + season = get_config().sba_season # Use the existing name-based search that actually works players = await self.get_players_by_name(query, season) diff --git a/services/team_service.py b/services/team_service.py index dfbb38b..aa824bd 100644 --- a/services/team_service.py +++ b/services/team_service.py @@ -79,7 +79,7 @@ class TeamService(BaseService[Team]): Exception: If there's an error communicating with the API Allows caller to distinguish between "no teams" vs "error occurred" """ - season = season or get_config().sba_current_season + season = season or get_config().sba_season params = [ ('owner_id', str(owner_id)), ('season', str(season)) @@ -139,7 +139,7 @@ class TeamService(BaseService[Team]): Team instance or None if not found """ try: - season = season or get_config().sba_current_season + season = season or get_config().sba_season params = [ ('team_abbrev', abbrev.upper()), ('season', str(season)) @@ -336,7 +336,7 @@ class TeamService(BaseService[Team]): Returns: List of teams in current season """ - return await self.get_teams_by_season(get_config().sba_current_season) + return await self.get_teams_by_season(get_config().sba_season) # Global service instance diff --git a/services/trade_builder.py b/services/trade_builder.py index bf3014a..060b5e1 100644 --- a/services/trade_builder.py +++ b/services/trade_builder.py @@ -66,7 +66,7 @@ class TradeBuilder: Extends the functionality of TransactionBuilder to support trades between teams. """ - def __init__(self, initiated_by: int, initiating_team: Team, season: int = get_config().sba_current_season): + def __init__(self, initiated_by: int, initiating_team: Team, season: int = get_config().sba_season): """ Initialize trade builder. diff --git a/services/transaction_builder.py b/services/transaction_builder.py index 659bb12..7ed344f 100644 --- a/services/transaction_builder.py +++ b/services/transaction_builder.py @@ -136,7 +136,7 @@ class RosterValidationResult: class TransactionBuilder: """Interactive transaction builder for complex multi-move transactions.""" - def __init__(self, team: Team, user_id: int, season: int = get_config().sba_current_season): + def __init__(self, team: Team, user_id: int, season: int = get_config().sba_season): """ Initialize transaction builder. diff --git a/tasks/draft_monitor.py b/tasks/draft_monitor.py index ff3c437..e1e21a7 100644 --- a/tasks/draft_monitor.py +++ b/tasks/draft_monitor.py @@ -115,7 +115,7 @@ class DraftMonitorTask: # Get current pick current_pick = await draft_pick_service.get_pick( - config.sba_current_season, + config.sba_season, draft_data.currentpick ) @@ -169,7 +169,7 @@ class DraftMonitorTask: # Get team's draft list draft_list = await draft_list_service.get_team_list( - config.sba_current_season, + config.sba_season, current_pick.owner.id ) @@ -315,7 +315,7 @@ class DraftMonitorTask: # Get current pick for mention current_pick = await draft_pick_service.get_pick( - config.sba_current_season, + config.sba_season, draft_data.currentpick ) diff --git a/test_real_data.py b/test_real_data.py index bbf66b5..3e7c8a6 100644 --- a/test_real_data.py +++ b/test_real_data.py @@ -68,7 +68,7 @@ async def test_player_search(): try: # Test 1: Search for a common name (should find multiple) logger.info("Testing search for common player name") - players = await player_service.get_players_by_name("Smith", get_config().sba_current_season) + players = await player_service.get_players_by_name("Smith", get_config().sba_season) logger.info("Common name search completed", search_term="Smith", results_found=len(players)) @@ -82,7 +82,7 @@ async def test_player_search(): # Test 2: Search for specific player (exact match) logger.info("Testing search for specific player") - players = await player_service.get_players_by_name("Mike Trout", get_config().sba_current_season) + players = await player_service.get_players_by_name("Mike Trout", get_config().sba_season) logger.info("Specific player search completed", search_term="Mike Trout", results_found=len(players)) @@ -144,7 +144,7 @@ async def test_player_service_methods(): # Test get_all with limit (need to include season) logger.info("Testing get_all with limit") players, total_count = await player_service.get_all(params=[ - ('season', str(get_config().sba_current_season)), + ('season', str(get_config().sba_season)), ('limit', '10') ]) @@ -153,7 +153,7 @@ async def test_player_service_methods(): retrieved_count=len(players), total_count=total_count, limit=10, - season=get_config().sba_current_season) + season=get_config().sba_season) if players: print(" Sample players:") @@ -164,7 +164,7 @@ async def test_player_service_methods(): if players: test_position = players[0].primary_position logger.info("Testing position search", position=test_position) - position_players = await player_service.get_players_by_position(test_position, get_config().sba_current_season) + position_players = await player_service.get_players_by_position(test_position, get_config().sba_season) print(f" ✅ Found {len(position_players)} players at position {test_position}") logger.info("Position search completed", diff --git a/tests/test_services_team_service.py b/tests/test_services_team_service.py index b8b99ac..b181b96 100644 --- a/tests/test_services_team_service.py +++ b/tests/test_services_team_service.py @@ -259,8 +259,8 @@ class TestTeamService: mock_data = { 'count': 2, 'teams': [ - self.create_team_data(1, 'TEA', season=get_config().sba_current_season), - self.create_team_data(2, 'TEB', season=get_config().sba_current_season) + self.create_team_data(1, 'TEA', season=get_config().sba_season), + self.create_team_data(2, 'TEB', season=get_config().sba_season) ] } mock_client.get.return_value = mock_data @@ -268,8 +268,8 @@ class TestTeamService: result = await team_service_instance.get_current_season_teams() assert len(result) == 2 - assert all(team.season == get_config().sba_current_season for team in result) - mock_client.get.assert_called_once_with('teams', params=[('season', str(get_config().sba_current_season))]) + assert all(team.season == get_config().sba_season for team in result) + mock_client.get.assert_called_once_with('teams', params=[('season', str(get_config().sba_season))]) @pytest.mark.asyncio async def test_error_handling(self, team_service_instance, mock_client): diff --git a/utils/autocomplete.py b/utils/autocomplete.py index a5ea14b..acce3c8 100644 --- a/utils/autocomplete.py +++ b/utils/autocomplete.py @@ -37,7 +37,7 @@ async def player_autocomplete( user_team = await get_user_major_league_team(interaction.user.id) # Search for players using the search endpoint - players = await player_service.search_players(current, limit=50, season=get_config().sba_current_season) + players = await player_service.search_players(current, limit=50, season=get_config().sba_season) # Separate players by team (user's team vs others) user_team_players = [] @@ -105,7 +105,7 @@ async def team_autocomplete( try: # Get all teams for current season - teams = await team_service.get_teams_by_season(get_config().sba_current_season) + teams = await team_service.get_teams_by_season(get_config().sba_season) # Filter teams by current input and limit to 25 matching_teams = [ @@ -146,7 +146,7 @@ async def major_league_team_autocomplete( try: # Get all teams for current season - all_teams = await team_service.get_teams_by_season(get_config().sba_current_season) + all_teams = await team_service.get_teams_by_season(get_config().sba_season) # Filter to only Major League teams using the model's helper method from models.team import RosterType diff --git a/utils/permissions.py b/utils/permissions.py index 199306b..1acff5a 100644 --- a/utils/permissions.py +++ b/utils/permissions.py @@ -55,7 +55,7 @@ async def get_user_team(user_id: int) -> Optional[dict]: config = get_config() team = await team_service.get_team_by_owner( owner_id=user_id, - season=config.sba_current_season + season=config.sba_season ) if team: diff --git a/utils/team_utils.py b/utils/team_utils.py index 3b8ff81..54001eb 100644 --- a/utils/team_utils.py +++ b/utils/team_utils.py @@ -13,7 +13,7 @@ from config import get_config async def get_user_major_league_team( user_id: int, - season: int = get_config().sba_current_season + season: int = get_config().sba_season ) -> Optional[Team]: """ Get the major league team owned by a Discord user. @@ -47,7 +47,7 @@ async def get_user_major_league_team( async def validate_user_has_team( interaction: discord.Interaction, - season: int = get_config().sba_current_season + season: int = get_config().sba_season ) -> Optional[Team]: """ Validate that a user has a major league team and send error message if not. @@ -76,7 +76,7 @@ async def validate_user_has_team( async def get_team_by_abbrev_with_validation( team_abbrev: str, interaction: discord.Interaction, - season: int = get_config().sba_current_season + season: int = get_config().sba_season ) -> Optional[Team]: """ Get a team by abbreviation with standard error messaging. diff --git a/views/embeds.py b/views/embeds.py index ec5c0b6..9abc712 100644 --- a/views/embeds.py +++ b/views/embeds.py @@ -155,7 +155,7 @@ class SBAEmbedTemplate(EmbedTemplate): embed.add_field( name="Season", - value=str(season or get_config().sba_current_season), + value=str(season or get_config().sba_season), inline=True ) @@ -192,7 +192,7 @@ class SBAEmbedTemplate(EmbedTemplate): embed = EmbedTemplate.create_base_embed( title=f"{team_abbrev} - {team_name}", - description=f"Season {season or get_config().sba_current_season} Team Information", + description=f"Season {season or get_config().sba_season} Team Information", color=color ) @@ -201,7 +201,7 @@ class SBAEmbedTemplate(EmbedTemplate): embed.add_field(name="Short Name", value=short_name, inline=True) embed.add_field(name="Abbreviation", value=team_abbrev, inline=True) - embed.add_field(name="Season", value=str(season or get_config().sba_current_season), inline=True) + embed.add_field(name="Season", value=str(season or get_config().sba_season), inline=True) if stadium: embed.add_field(name="Stadium", value=stadium, inline=True) @@ -276,7 +276,7 @@ class SBAEmbedTemplate(EmbedTemplate): embed = EmbedTemplate.create_base_embed( title=f"{team_abbrev} - {roster_type}", - description=f"{team_name} • Season {season or get_config().sba_current_season}", + description=f"{team_name} • Season {season or get_config().sba_season}", color=color )