Add s_type to /plays
This commit is contained in:
parent
183e4bc91e
commit
0d13fc939f
@ -138,7 +138,7 @@ async def get_plays(
|
|||||||
is_go_ahead: Optional[bool] = None, is_tied: Optional[bool] = None, is_new_inning: Optional[bool] = None,
|
is_go_ahead: Optional[bool] = None, is_tied: Optional[bool] = None, is_new_inning: Optional[bool] = None,
|
||||||
min_wpa: Optional[float] = None, max_wpa: Optional[float] = None, pitcher_team_id: list = Query(default=None),
|
min_wpa: Optional[float] = None, max_wpa: Optional[float] = None, pitcher_team_id: list = Query(default=None),
|
||||||
short_output: Optional[bool] = False, sort: Optional[str] = None, limit: Optional[int] = 200,
|
short_output: Optional[bool] = False, sort: Optional[str] = None, limit: Optional[int] = 200,
|
||||||
page_num: Optional[int] = 1):
|
page_num: Optional[int] = 1, s_type: Literal['regular', 'post', 'total', None] = None):
|
||||||
all_plays = StratPlay.select()
|
all_plays = StratPlay.select()
|
||||||
|
|
||||||
if season is not None:
|
if season is not None:
|
||||||
@ -240,6 +240,13 @@ async def get_plays(
|
|||||||
all_plays = all_plays.where(StratPlay.wpa <= max_wpa)
|
all_plays = all_plays.where(StratPlay.wpa <= max_wpa)
|
||||||
if play_num is not None:
|
if play_num is not None:
|
||||||
all_plays = all_plays.where(StratPlay.play_num << play_num)
|
all_plays = all_plays.where(StratPlay.play_num << play_num)
|
||||||
|
if s_type is not None:
|
||||||
|
season_games = StratGame.select()
|
||||||
|
if s_type == 'regular':
|
||||||
|
season_games = season_games.where(StratGame.week <= 18)
|
||||||
|
elif s_type == 'post':
|
||||||
|
season_games = season_games.where(StratGame.week > 18)
|
||||||
|
all_plays = all_plays.where(StratPlay.game << season_games)
|
||||||
|
|
||||||
if limit < 1:
|
if limit < 1:
|
||||||
limit = 1
|
limit = 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user