Stat updates for website

This commit is contained in:
Cal Corum 2023-09-10 19:16:36 -05:00
parent aa53c4072b
commit d8ef59dae0
2 changed files with 25 additions and 1 deletions

View File

@ -142,7 +142,8 @@ async def get_totalstats(
fn.SUM(PitchingStat.win).alias('sum_win'), fn.SUM(PitchingStat.loss).alias('sum_loss'),
fn.SUM(PitchingStat.hold).alias('sum_hold'), fn.SUM(PitchingStat.sv).alias('sum_sv'),
fn.SUM(PitchingStat.bsv).alias('sum_bsv'), fn.SUM(PitchingStat.irs).alias('sum_irs'),
fn.SUM(PitchingStat.gs).alias('sum_gs'), PitchingStat.team)
fn.SUM(PitchingStat.gs).alias('sum_gs'), fn.COUNT(PitchingStat.game).alias('sum_games'),
PitchingStat.team)
.where(PitchingStat.season == season)
.having(fn.SUM(PitchingStat.ip) >= ip_min)
)
@ -219,6 +220,7 @@ async def get_totalstats(
'ir': x.sum_ir,
'irs': x.sum_irs,
'gs': x.sum_gs,
'games': x.sum_games,
'win': x.sum_win,
'loss': x.sum_loss,
'hold': x.sum_hold,

View File

@ -262,8 +262,16 @@ async def get_batting_totals(
season_games = StratGame.select()
if season is not None:
season_games = season_games.where(StratGame.season << season)
if week is not None and s_type is not None:
raise HTTPException(status_code=400, detail=f'Week and s_type parameters cannot be used in the same query')
if week is not None:
season_games = season_games.where(StratGame.week << week)
if s_type is not None:
if s_type == 'regular':
season_games = season_games.where(StratGame.week <= 18)
elif s_type == 'post':
season_games = season_games.where(StratGame.week > 18)
if manager_id is not None:
season_games = season_games.where(
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)
@ -491,8 +499,15 @@ async def get_pitching_totals(
season_games = StratGame.select()
if season is not None:
season_games = season_games.where(StratGame.season << season)
if week is not None and s_type is not None:
raise HTTPException(status_code=400, detail=f'Week and s_type parameters cannot be used in the same query')
if week is not None:
season_games = season_games.where(StratGame.week << week)
if s_type is not None:
if s_type == 'regular':
season_games = season_games.where(StratGame.week <= 18)
elif s_type == 'post':
season_games = season_games.where(StratGame.week > 18)
if manager_id is not None:
season_games = season_games.where(
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)
@ -688,8 +703,15 @@ async def get_fielding_totals(
season_games = StratGame.select()
if season is not None:
season_games = season_games.where(StratGame.season << season)
if week is not None and s_type is not None:
raise HTTPException(status_code=400, detail=f'Week and s_type parameters cannot be used in the same query')
if week is not None:
season_games = season_games.where(StratGame.week << week)
if s_type is not None:
if s_type == 'regular':
season_games = season_games.where(StratGame.week <= 18)
elif s_type == 'post':
season_games = season_games.where(StratGame.week > 18)
if manager_id is not None:
season_games = season_games.where(
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)