Update data_cache.py
This commit is contained in:
parent
6baa989aae
commit
2a00e9d6da
@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Optional
|
||||
from typing import Optional, Literal
|
||||
|
||||
from db_calls import db_get
|
||||
|
||||
@ -86,6 +86,37 @@ class BattingCard:
|
||||
hand: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class CardPosition:
|
||||
player_id: int
|
||||
variant: int
|
||||
position: Literal['P', 'C', '1B', '2B', '3B', 'SS', 'LF', 'CF', 'RF', 'DH']
|
||||
innings: int
|
||||
range: int
|
||||
error: int
|
||||
arm: Optional[int] = None
|
||||
pb: Optional[int] = None
|
||||
overthrow: Optional[int] = None
|
||||
|
||||
def to_dict(self):
|
||||
return_val = {
|
||||
'player_id': self.player_id,
|
||||
'variant': self.variant,
|
||||
'position': self.position,
|
||||
'innings': self.innings,
|
||||
'range': self.range,
|
||||
'error': self.error
|
||||
}
|
||||
if self.arm is not None:
|
||||
return_val['arm'] = self.arm
|
||||
if self.pb is not None:
|
||||
return_val['pb'] = self.pb
|
||||
if self.overthrow is not None:
|
||||
return_val['overthrow'] = self.overthrow
|
||||
|
||||
return return_val
|
||||
|
||||
|
||||
@dataclass
|
||||
class BattingRatings:
|
||||
homerun: float
|
||||
@ -280,7 +311,7 @@ async def get_pd_pitchingcard(player_id: int, variant: Optional[int] = 0):
|
||||
break
|
||||
|
||||
if None in [vl_data, vr_data]:
|
||||
raise KeyError(f'Could not find batting card ratings for player {player_id} variant {variant}')
|
||||
raise KeyError(f'Could not find pitching card ratings for player {player_id} variant {variant}')
|
||||
|
||||
logging.debug(f'prepping the pitching card')
|
||||
pc_data = vl_data['pitchingcard']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user