Merge pull request #5 from calcorum/bug-decision-data

Pitcher decision bug fixed
This commit is contained in:
Cal Corum 2025-10-27 14:57:51 -05:00 committed by GitHub
commit 78a6993204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -881,14 +881,10 @@ async def get_pitching_totals(
if 'player' in group_by:
decision_query = decision_query.where(Decision.pitcher == x.pitcher_id)
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)
if team_obj:
# Get all players on this team for this season
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)
decision_query = decision_query.where(Decision.team == team_obj.id)
if 'game' in group_by:
decision_query = decision_query.where(Decision.game == x.game_id)