Add poop_max to game summary

This commit is contained in:
Cal Corum 2024-12-23 10:14:02 -06:00
parent 21fe5c419a
commit 0b8234f9d6

View File

@ -878,7 +878,7 @@ async def get_pitching_totals(
@router.get('/game-summary/{game_id}') @router.get('/game-summary/{game_id}')
async def get_game_summary( async def get_game_summary(
game_id: int, csv: Optional[bool] = False, short_output: Optional[bool] = False, tp_max: Optional[int] = 1): game_id: int, csv: Optional[bool] = False, short_output: Optional[bool] = False, tp_max: Optional[int] = 1, poop_max: Optional[int] = 1):
this_game = StratGame.get_or_none(StratGame.id == game_id) this_game = StratGame.get_or_none(StratGame.id == game_id)
if this_game is None: if this_game is None:
db.close() db.close()
@ -1000,7 +1000,7 @@ async def get_game_summary(
'home': all_errors.where(StratPlay.defender_team == this_game.home_team).count() 'home': all_errors.where(StratPlay.defender_team == this_game.home_team).count()
}, },
'top-players': sorted(top_players, key=lambda x: x['re24'], reverse=True)[:tp_max], 'top-players': sorted(top_players, key=lambda x: x['re24'], reverse=True)[:tp_max],
'pooper': sorted(bot_players, key=lambda x: x['re24'])[0], 'pooper': sorted(bot_players, key=lambda x: x['re24'])[:poop_max],
'pitchers': { 'pitchers': {
'win': model_to_dict(winner.get().pitcher, recurse=not short_output), 'win': model_to_dict(winner.get().pitcher, recurse=not short_output),
'loss': model_to_dict(loser.get().pitcher, recurse=not short_output), 'loss': model_to_dict(loser.get().pitcher, recurse=not short_output),