Pitcher decision bug fixed

This commit is contained in:
Cal Corum 2025-10-27 14:57:14 -05:00
parent 3bf159e54a
commit 0c865a29bc

View File

@ -881,14 +881,10 @@ async def get_pitching_totals(
if 'player' in group_by: if 'player' in group_by:
decision_query = decision_query.where(Decision.pitcher == x.pitcher_id) decision_query = decision_query.where(Decision.pitcher == x.pitcher_id)
if 'team' in group_by and hasattr(x, 'pitcher_team') and x.pitcher_team: if 'team' in group_by and hasattr(x, 'pitcher_team') and x.pitcher_team:
# For team filtering, need to correlate through pitcher's team # Filter by the team field in Decision table directly
team_obj = getattr(x, 'pitcher_team', None) team_obj = getattr(x, 'pitcher_team', None)
if team_obj: if team_obj:
# Get all players on this team for this season decision_query = decision_query.where(Decision.team == team_obj.id)
team_players = Player.select(Player.id).where(
(Player.team == team_obj.id) & (Player.season == team_obj.season)
)
decision_query = decision_query.where(Decision.pitcher << team_players)
if 'game' in group_by: if 'game' in group_by:
decision_query = decision_query.where(Decision.game == x.game_id) decision_query = decision_query.where(Decision.game == x.game_id)