Compare commits
7 Commits
867e8ce888
...
053fcbab05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
053fcbab05 | ||
| e7c8b59201 | |||
|
|
ae8c20ea1c | ||
| 9096a4b976 | |||
|
|
5f86c8cb20 | ||
| 20f727a119 | |||
|
|
86b4338b66 |
@ -104,7 +104,7 @@ async def get_packs(
|
||||
|
||||
|
||||
@router.get('/{pack_id}')
|
||||
async def get_one_pack(pack_id, csv: Optional[bool] = False):
|
||||
async def get_one_pack(pack_id: int, csv: Optional[bool] = False):
|
||||
try:
|
||||
this_pack = Pack.get_by_id(pack_id)
|
||||
except Exception:
|
||||
|
||||
@ -582,7 +582,7 @@ async def search_players(
|
||||
|
||||
|
||||
@router.get("/{player_id}")
|
||||
async def get_one_player(player_id, csv: Optional[bool] = False):
|
||||
async def get_one_player(player_id: int, csv: Optional[bool] = False):
|
||||
try:
|
||||
this_player = Player.get_by_id(player_id)
|
||||
except Exception:
|
||||
@ -1114,7 +1114,7 @@ async def post_image_reset(
|
||||
|
||||
|
||||
@router.delete("/{player_id}")
|
||||
async def delete_player(player_id, token: str = Depends(oauth2_scheme)):
|
||||
async def delete_player(player_id: int, token: str = Depends(oauth2_scheme)):
|
||||
if not valid_token(token):
|
||||
logging.warning(f"Bad Token: {token}")
|
||||
raise HTTPException(
|
||||
|
||||
@ -132,9 +132,6 @@ async def get_teams(
|
||||
if ranking_max is not None:
|
||||
all_teams = all_teams.where(Team.ranking <= ranking_max)
|
||||
|
||||
if ranking_max is not None:
|
||||
all_teams = all_teams.where(Team.ranking <= ranking_max)
|
||||
|
||||
if has_guide is not None:
|
||||
# Use boolean comparison (PostgreSQL-compatible)
|
||||
if not has_guide:
|
||||
@ -170,7 +167,7 @@ async def get_teams(
|
||||
|
||||
|
||||
@router.get("/{team_id}")
|
||||
async def get_one_team(team_id, inc_packs: bool = True, csv: Optional[bool] = False):
|
||||
async def get_one_team(team_id: int, inc_packs: bool = True, csv: Optional[bool] = False):
|
||||
try:
|
||||
this_team = Team.get_by_id(team_id)
|
||||
except Exception:
|
||||
@ -276,7 +273,6 @@ def get_scouting_dfs(allowed_players, position: str):
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_total_ops(df_data):
|
||||
ops_vl = df_data["obp_vl"] + df_data["slg_vl"]
|
||||
ops_vr = df_data["obp_vr"] + df_data["slg_vr"]
|
||||
@ -584,15 +580,18 @@ def sort_pitchers(pitching_card_query) -> DataFrame | None:
|
||||
pitcher_df = pd.DataFrame(all_s).set_index("player", drop=False)
|
||||
logging.debug(f"pitcher_df: {pitcher_df}")
|
||||
|
||||
card_ids = pitcher_df["id"].tolist()
|
||||
ratings_map = {
|
||||
(r.pitchingcard_id, r.vs_hand): r
|
||||
for r in PitchingCardRatings.select().where(
|
||||
(PitchingCardRatings.pitchingcard_id << card_ids)
|
||||
& (PitchingCardRatings.vs_hand << ["L", "R"])
|
||||
)
|
||||
}
|
||||
|
||||
def get_total_ops(df_data):
|
||||
vlval = PitchingCardRatings.get_or_none(
|
||||
PitchingCardRatings.pitchingcard_id == df_data["id"],
|
||||
PitchingCardRatings.vs_hand == "L",
|
||||
)
|
||||
vrval = PitchingCardRatings.get_or_none(
|
||||
PitchingCardRatings.pitchingcard_id == df_data["id"],
|
||||
PitchingCardRatings.vs_hand == "R",
|
||||
)
|
||||
vlval = ratings_map.get((df_data["id"], "L"))
|
||||
vrval = ratings_map.get((df_data["id"], "R"))
|
||||
|
||||
ops_vl = vlval.obp + vlval.slg
|
||||
ops_vr = vrval.obp + vrval.slg
|
||||
@ -661,15 +660,18 @@ async def get_team_sp(
|
||||
starter_df = pd.DataFrame(all_s).set_index("player", drop=False)
|
||||
logging.debug(f"starter_df: {starter_df}")
|
||||
|
||||
card_ids = starter_df["id"].tolist()
|
||||
ratings_map = {
|
||||
(r.pitchingcard_id, r.vs_hand): r
|
||||
for r in PitchingCardRatings.select().where(
|
||||
(PitchingCardRatings.pitchingcard_id << card_ids)
|
||||
& (PitchingCardRatings.vs_hand << ["L", "R"])
|
||||
)
|
||||
}
|
||||
|
||||
def get_total_ops(df_data):
|
||||
vlval = PitchingCardRatings.get_or_none(
|
||||
PitchingCardRatings.pitchingcard_id == df_data["id"],
|
||||
PitchingCardRatings.vs_hand == "L",
|
||||
)
|
||||
vrval = PitchingCardRatings.get_or_none(
|
||||
PitchingCardRatings.pitchingcard_id == df_data["id"],
|
||||
PitchingCardRatings.vs_hand == "R",
|
||||
)
|
||||
vlval = ratings_map.get((df_data["id"], "L"))
|
||||
vrval = ratings_map.get((df_data["id"], "R"))
|
||||
|
||||
ops_vl = vlval.obp + vlval.slg
|
||||
ops_vr = vrval.obp + vrval.slg
|
||||
|
||||
Loading…
Reference in New Issue
Block a user