Update stratplay.py

added is_scoring_play
added _ to is_defender_or_catcher
This commit is contained in:
Cal Corum 2023-08-22 10:30:17 -05:00
parent 1b653943a5
commit 211055d8b3

View File

@ -115,11 +115,11 @@ class PlayList(BaseModel):
plays: List[PlayModel]
@router.get('') # Want to add runner parameters
@router.get('')
async def get_plays(
game_id: list = Query(default=None), batter_id: list = Query(default=None), season: list = Query(default=None),
week: list = Query(default=None), has_defender: Optional[bool] = None, has_catcher: Optional[bool] = None,
has_defenderorcatcher: Optional[bool] = None,
has_defender_or_catcher: Optional[bool] = None, is_scoring_play: Optional[bool] = None,
pitcher_id: list = Query(default=None), obc: list = Query(default=None), inning: list = Query(default=None),
batting_order: list = Query(default=None), starting_outs: list = Query(default=None),
batter_pos: list = Query(default=None), catcher_id: list = Query(default=None),
@ -143,7 +143,7 @@ async def get_plays(
all_plays = all_plays.where(StratPlay.defender.is_null(False))
if has_catcher is not None:
all_plays = all_plays.where(StratPlay.catcher.is_null(False))
if has_defenderorcatcher is not None:
if has_defender_or_catcher is not None:
all_plays = all_plays.where(
(StratPlay.catcher.is_null(False)) | (StratPlay.defender.is_null(False))
)
@ -212,6 +212,11 @@ async def get_plays(
all_plays = all_plays.where(StratPlay.is_tied == is_tied)
if is_new_inning is not None:
all_plays = all_plays.where(StratPlay.is_new_inning == is_new_inning)
if is_scoring_play is not None:
all_plays = all_plays.where(
(StratPlay.on_first_final == 4) | (StratPlay.on_second_final == 4) | (StratPlay.on_third_final == 4) |
(StratPlay.batter_final == 4)
)
if limit > 5000:
limit = 5000