Stat updates for website
This commit is contained in:
parent
aa53c4072b
commit
d8ef59dae0
@ -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.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.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.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)
|
.where(PitchingStat.season == season)
|
||||||
.having(fn.SUM(PitchingStat.ip) >= ip_min)
|
.having(fn.SUM(PitchingStat.ip) >= ip_min)
|
||||||
)
|
)
|
||||||
@ -219,6 +220,7 @@ async def get_totalstats(
|
|||||||
'ir': x.sum_ir,
|
'ir': x.sum_ir,
|
||||||
'irs': x.sum_irs,
|
'irs': x.sum_irs,
|
||||||
'gs': x.sum_gs,
|
'gs': x.sum_gs,
|
||||||
|
'games': x.sum_games,
|
||||||
'win': x.sum_win,
|
'win': x.sum_win,
|
||||||
'loss': x.sum_loss,
|
'loss': x.sum_loss,
|
||||||
'hold': x.sum_hold,
|
'hold': x.sum_hold,
|
||||||
|
|||||||
@ -262,8 +262,16 @@ async def get_batting_totals(
|
|||||||
season_games = StratGame.select()
|
season_games = StratGame.select()
|
||||||
if season is not None:
|
if season is not None:
|
||||||
season_games = season_games.where(StratGame.season << season)
|
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:
|
if week is not None:
|
||||||
season_games = season_games.where(StratGame.week << week)
|
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:
|
if manager_id is not None:
|
||||||
season_games = season_games.where(
|
season_games = season_games.where(
|
||||||
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)
|
(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()
|
season_games = StratGame.select()
|
||||||
if season is not None:
|
if season is not None:
|
||||||
season_games = season_games.where(StratGame.season << season)
|
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:
|
if week is not None:
|
||||||
season_games = season_games.where(StratGame.week << week)
|
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:
|
if manager_id is not None:
|
||||||
season_games = season_games.where(
|
season_games = season_games.where(
|
||||||
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)
|
(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()
|
season_games = StratGame.select()
|
||||||
if season is not None:
|
if season is not None:
|
||||||
season_games = season_games.where(StratGame.season << season)
|
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:
|
if week is not None:
|
||||||
season_games = season_games.where(StratGame.week << week)
|
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:
|
if manager_id is not None:
|
||||||
season_games = season_games.where(
|
season_games = season_games.where(
|
||||||
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)
|
(StratGame.away_manager_id << manager_id) | (StratGame.home_manager_id << manager_id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user