Final test updates

This commit is contained in:
Cal Corum 2023-10-03 12:07:34 -05:00
parent b5e3c40d62
commit 1776df7173
2 changed files with 11 additions and 10 deletions

View File

@ -35,8 +35,9 @@ class PitchingCardRatingsModel(pydantic.BaseModel):
hbp: float = 0.0
walk: float = 0.0
strikeout: float = 0.0
fo_slap: float = 0.0
fo_center: float = 0.0
flyout_lf_b: float = 0.0
flyout_cf_b: float = 0.0
flyout_rf_b: float = 0.0
groundout_a: float = 0.0
groundout_b: float = 0.0
xcheck_p: float = 0.0
@ -74,12 +75,12 @@ class PitchingCardRatingsModel(pydantic.BaseModel):
values['homerun'] + values['bp_homerun'] + values['triple'] + values['double_three'] +
values['double_two'] + values['double_cf'] + values['single_two'] + values['single_one'] +
values['single_center'] + values['bp_single'] + values['hbp'] + values['walk'] +
values['strikeout'] + values['fo_slap'] + values['fo_center'] + values['groundout_a'] +
values['groundout_b'] + values['xcheck_p'] + values['xcheck_c'] + values['xcheck_1b'] +
values['xcheck_2b'] + values['xcheck_3b'] + values['xcheck_ss'] + values['xcheck_lf'] +
values['xcheck_cf'] + values['xcheck_rf'])
values['strikeout'] + values['flyout_lf_b'] + values['flyout_cf_b'] + values['flyout_rf_b'] +
values['groundout_a'] + values['groundout_b'] + values['xcheck_p'] + values['xcheck_c'] +
values['xcheck_1b'] + values['xcheck_2b'] + values['xcheck_3b'] + values['xcheck_ss'] +
values['xcheck_lf'] + values['xcheck_cf'] + values['xcheck_rf'])
if total_chances != 108:
if round(total_chances) != 108:
raise ValueError("Must have exactly 108 chances on the card")
return values
@ -106,11 +107,11 @@ async def get_card_ratings(
if pitchingcard_id is not None:
all_ratings = all_ratings.where(PitchingCardRatings.pitchingcard_id << pitchingcard_id)
if vs_hand is not None:
all_ratings = all_ratings.where(PitchingCardRatings.vs_hand << vs_hand[-1])
all_ratings = all_ratings.where(PitchingCardRatings.vs_hand == vs_hand[-1])
if cardset_id is not None:
set_players = Player.select(Player.player_id).where(Player.cardset_id << cardset_id)
set_cards = PitchingCard.select(PitchingCard.id).where(PitchingCard.player << set_players)
all_ratings = all_ratings.where(PitchingCardRatings.battingcard << set_cards)
all_ratings = all_ratings.where(PitchingCardRatings.pitchingcard << set_cards)
if csv:
return_val = query_to_csv(all_ratings)

View File

@ -329,7 +329,7 @@ async def get_one_player(player_id, csv: Optional[bool] = False):
return return_val
@router.get('/{player_id}/batting-card')
@router.get('/{player_id}/battingcard')
async def get_player_card(
request: Request, player_id: int, variant: int = 0, d: str = None, html: Optional[bool] = False):
if os.path.isfile(f'storage/cards/{player_id}-{d}-v{variant}.png') and html is False: