Update stratplay.py
Add pitcher_team_id to raw plays
This commit is contained in:
parent
9f635630e5
commit
85b855492f
@ -131,7 +131,7 @@ async def get_plays(
|
||||
run: Optional[int] = None, e_run: Optional[int] = None, rbi: list = Query(default=None),
|
||||
outs: list = Query(default=None), wild_pitch: Optional[int] = None, is_final_out: 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,
|
||||
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):
|
||||
all_plays = StratPlay.select()
|
||||
|
||||
@ -171,6 +171,11 @@ async def get_plays(
|
||||
all_plays = all_plays.where(StratPlay.defender_id << defender_id)
|
||||
if runner_id is not None:
|
||||
all_plays = all_plays.where(StratPlay.runner_id << runner_id)
|
||||
if pitcher_team_id is not None:
|
||||
all_teams = Team.select().where(Team.id << pitcher_team_id)
|
||||
all_plays = all_plays.where(
|
||||
(StratPlay.pitcher_team << all_teams)
|
||||
)
|
||||
if offense_team_id is not None:
|
||||
all_teams = Team.select().where(Team.id << offense_team_id)
|
||||
all_plays = all_plays.where(
|
||||
@ -982,5 +987,17 @@ async def delete_plays_game(game_id: int, token: str = Depends(oauth2_scheme)):
|
||||
raise HTTPException(status_code=500, detail=f'No plays matching Game ID {game_id} were deleted')
|
||||
|
||||
|
||||
@router.post('/erun-check')
|
||||
async def post_erun_check(token: str = Depends(oauth2_scheme)):
|
||||
if not valid_token(token):
|
||||
logging.warning(f'post_erun_check - Bad Token: {token}')
|
||||
raise HTTPException(status_code=401, detail='Unauthorized')
|
||||
|
||||
all_plays = StratPlay.update(run=1).where((StratPlay.e_run == 1) & (StratPlay.run == 0))
|
||||
count = all_plays.execute()
|
||||
db.close()
|
||||
return count
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user