Season 8 Draft Fixes
This commit is contained in:
parent
8f316fb406
commit
6c03eabfe3
@ -246,7 +246,7 @@ class Team(BaseModel):
|
|||||||
return [self.gmid]
|
return [self.gmid]
|
||||||
|
|
||||||
def get_this_week(self):
|
def get_this_week(self):
|
||||||
active_team = Player.select_season(self.season).where(Player.team == self)
|
active_team = Player.select_season(self.season).where(Player.team == self).order_by(Player.wara)
|
||||||
|
|
||||||
active_roster = {'C': 0, '1B': 0, '2B': 0, '3B': 0, 'SS': 0, 'LF': 0, 'CF': 0, 'RF': 0, 'DH': 0,
|
active_roster = {'C': 0, '1B': 0, '2B': 0, '3B': 0, 'SS': 0, 'LF': 0, 'CF': 0, 'RF': 0, 'DH': 0,
|
||||||
'SP': 0, 'RP': 0, 'CP': 0, 'WARa': 0, 'players': []}
|
'SP': 0, 'RP': 0, 'CP': 0, 'WARa': 0, 'players': []}
|
||||||
|
|||||||
@ -31,7 +31,8 @@ async def get_picks(
|
|||||||
owner_team_id: list = Query(default=None), orig_team_id: list = Query(default=None),
|
owner_team_id: list = Query(default=None), orig_team_id: list = Query(default=None),
|
||||||
pick_round_start: Optional[int] = None, pick_round_end: Optional[int] = None, traded: Optional[bool] = None,
|
pick_round_start: Optional[int] = None, pick_round_end: Optional[int] = None, traded: Optional[bool] = None,
|
||||||
overall: Optional[int] = None, overall_start: Optional[int] = None, overall_end: Optional[int] = None,
|
overall: Optional[int] = None, overall_start: Optional[int] = None, overall_end: Optional[int] = None,
|
||||||
short_output: Optional[bool] = True, sort: Optional[str] = None, limit: Optional[int] = None):
|
short_output: Optional[bool] = False, sort: Optional[str] = None, limit: Optional[int] = None,
|
||||||
|
player_id: list = Query(default=None), player_taken: Optional[bool] = None):
|
||||||
all_picks = DraftPick.select().where(DraftPick.season == season)
|
all_picks = DraftPick.select().where(DraftPick.season == season)
|
||||||
|
|
||||||
if owner_team_abbrev is not None:
|
if owner_team_abbrev is not None:
|
||||||
@ -63,6 +64,8 @@ async def get_picks(
|
|||||||
if pick_round_start is not None and pick_round_end is not None and pick_round_end < pick_round_start:
|
if pick_round_start is not None and pick_round_end is not None and pick_round_end < pick_round_start:
|
||||||
raise HTTPException(status_code=400, detail=f'pick_round_end must be greater than or equal to pick_round_start')
|
raise HTTPException(status_code=400, detail=f'pick_round_end must be greater than or equal to pick_round_start')
|
||||||
|
|
||||||
|
if player_id is not None:
|
||||||
|
all_picks = all_picks.where(DraftPick.player_id << player_id)
|
||||||
if pick_round_start is not None:
|
if pick_round_start is not None:
|
||||||
all_picks = all_picks.where(DraftPick.round >= pick_round_start)
|
all_picks = all_picks.where(DraftPick.round >= pick_round_start)
|
||||||
if pick_round_end is not None:
|
if pick_round_end is not None:
|
||||||
@ -75,6 +78,8 @@ async def get_picks(
|
|||||||
all_picks = all_picks.where(DraftPick.overall >= overall_start)
|
all_picks = all_picks.where(DraftPick.overall >= overall_start)
|
||||||
if overall_end is not None:
|
if overall_end is not None:
|
||||||
all_picks = all_picks.where(DraftPick.overall <= overall_end)
|
all_picks = all_picks.where(DraftPick.overall <= overall_end)
|
||||||
|
if player_taken is not None:
|
||||||
|
all_picks = all_picks.where(DraftPick.player.is_null(not player_taken))
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
all_picks = all_picks.limit(limit)
|
all_picks = all_picks.limit(limit)
|
||||||
|
|
||||||
|
|||||||
@ -18,9 +18,9 @@ async def get_standings(
|
|||||||
division_abbrev: Optional[str] = None, short_output: Optional[bool] = False):
|
division_abbrev: Optional[str] = None, short_output: Optional[bool] = False):
|
||||||
standings = Standings.select_season(season)
|
standings = Standings.select_season(season)
|
||||||
|
|
||||||
if standings.count() == 0:
|
# if standings.count() == 0:
|
||||||
db.close()
|
# db.close()
|
||||||
raise HTTPException(status_code=404, detail=f'No output for season {season}')
|
# raise HTTPException(status_code=404, detail=f'No output for season {season}')
|
||||||
|
|
||||||
if team_abbrev is not None:
|
if team_abbrev is not None:
|
||||||
t_query = Team.select().where(fn.Lower(Team.abbrev) << [x.lower() for x in team_abbrev])
|
t_query = Team.select().where(fn.Lower(Team.abbrev) << [x.lower() for x in team_abbrev])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user