Season 8 updates to players
This commit is contained in:
parent
115a50c50a
commit
8f316fb406
@ -31,6 +31,8 @@ class PlayerModel(pydantic.BaseModel):
|
||||
pos_6: Optional[str] = None
|
||||
pos_7: Optional[str] = None
|
||||
pos_8: Optional[str] = None
|
||||
vanity_card: Optional[str] = None
|
||||
headshot: Optional[str] = None
|
||||
last_game: Optional[str] = None
|
||||
last_game2: Optional[str] = None
|
||||
il_return: Optional[str] = None
|
||||
@ -47,13 +49,17 @@ class PlayerList(pydantic.BaseModel):
|
||||
@router.get('')
|
||||
async def get_players(
|
||||
season: Optional[int], name: Optional[str] = None, team_id: list = Query(default=None),
|
||||
pos: list = Query(default=None), is_injured: Optional[bool] = None, sort: Optional[str] = None,
|
||||
short_output: Optional[bool] = False, csv: Optional[bool] = False):
|
||||
pos: list = Query(default=None), strat_code: list = Query(default=None), is_injured: Optional[bool] = None,
|
||||
sort: Optional[str] = None, short_output: Optional[bool] = False, csv: Optional[bool] = False):
|
||||
all_players = Player.select_season(season)
|
||||
|
||||
if team_id is not None:
|
||||
all_players = all_players.where(Player.team_id << team_id)
|
||||
|
||||
if strat_code is not None:
|
||||
code_list = [x.lower() for x in strat_code]
|
||||
all_players = all_players.where(fn.Lower(Player.strat_code) << code_list)
|
||||
|
||||
if name is not None:
|
||||
all_players = all_players.where(fn.lower(Player.name) == name.lower())
|
||||
|
||||
@ -82,7 +88,7 @@ async def get_players(
|
||||
player_list = [
|
||||
['name', 'wara', 'image', 'image2', 'team', 'season', 'pitcher_injury', 'pos_1', 'pos_2', 'pos_3',
|
||||
'pos_4', 'pos_5', 'pos_6', 'pos_7', 'pos_8', 'last_game', 'last_game2', 'il_return', 'demotion_week',
|
||||
'headshot', 'vanity_card', 'strat_code', 'bbref_id', 'injury_rating']
|
||||
'headshot', 'vanity_card', 'strat_code', 'bbref_id', 'injury_rating', 'player_id']
|
||||
]
|
||||
for line in all_players:
|
||||
player_list.append(
|
||||
@ -90,7 +96,7 @@ async def get_players(
|
||||
line.name, line.wara, line.image, line.image2, line.team.abbrev, line.season, line.pitcher_injury,
|
||||
line.pos_1, line.pos_2, line.pos_3, line.pos_4, line.pos_5, line.pos_6, line.pos_7, line.pos_8,
|
||||
line.last_game, line.last_game2, line.il_return, line.demotion_week, line.headshot,
|
||||
line.vanity_card, line.strat_code.replace(",", "-_-"), line.bbref_id, line.injury_rating
|
||||
line.vanity_card, line.strat_code.replace(",", "-_-"), line.bbref_id, line.injury_rating, line.id
|
||||
]
|
||||
)
|
||||
return_players = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user