From 183e4bc91ee360f405f1b9adb99bec88745f7415 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 29 Jan 2024 00:03:49 -0600 Subject: [PATCH] Season 8 Decision Fix --- app/routers_v3/decisions.py | 11 +++++++++-- app/routers_v3/stratplay.py | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/routers_v3/decisions.py b/app/routers_v3/decisions.py index c6fd865..bcaa877 100644 --- a/app/routers_v3/decisions.py +++ b/app/routers_v3/decisions.py @@ -73,8 +73,15 @@ async def get_decisions( # all_players = Player.select().where(Player.team_id << team_id) # all_dec = all_dec.where(Decision.pitcher << all_players) if team_id is not None: - all_teams = Team.select().where(Team.id << team_id) - all_dec = all_dec.where(Decision.team << all_teams) + s8_teams = [int(x) for x in team_id if int(x) <= 350] + if season is not None and 8 in season or s8_teams: + all_teams = Team.select().where(Team.id << team_id) + all_games = StratGame.select().where( + (StratGame.away_team << all_teams) | (StratGame.home_team << all_teams)) + all_dec = all_dec.where(Decision.game << all_games) + else: + all_teams = Team.select().where(Team.id << team_id) + all_dec = all_dec.where(Decision.team << all_teams) if s_type is not None: all_games = StratGame.select().where(StratGame.season_type == s_type) all_dec = all_dec.where(Decision.game << all_games) diff --git a/app/routers_v3/stratplay.py b/app/routers_v3/stratplay.py index 81a1078..0b59eb4 100644 --- a/app/routers_v3/stratplay.py +++ b/app/routers_v3/stratplay.py @@ -639,7 +639,13 @@ async def get_pitching_totals( if team_id is not None: all_teams = Team.select().where(Team.id << team_id) pit_plays = pit_plays.where(StratPlay.pitcher_team << all_teams) - all_dec = all_dec.where(Decision.team << all_teams) + s8_teams = [x for x in team_id if int(x) <= 350] + if s8_teams: + all_games = StratGame.select().where( + (StratGame.away_team << all_teams) | (StratGame.home_team << all_teams)) + all_dec = all_dec.where(Decision.game << all_games) + else: + all_dec = all_dec.where(Decision.team << all_teams) if obc is not None: pit_plays = pit_plays.where(StratPlay.on_base_code << obc) @@ -793,7 +799,7 @@ async def get_pitching_totals( 'lob_2outs': x.count_lo1_3out + x.count_lo2_3out + x.count_lo3_3out, 'rbi%': rbi_rate, 'week': this_week, - 're24_primary': x.sum_repri * -1 + 're24_primary': x.sum_repri * -1 if x.sum_repri is not None else None }) db.close() if csv: