feat: add limit/pagination to pitchingcardratings endpoint (#136)
Closes #136 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6a217f97ee
commit
2f56942721
@ -143,6 +143,7 @@ async def get_card_ratings(
|
||||
short_output: bool = False,
|
||||
csv: bool = False,
|
||||
cardset_id: list = Query(default=None),
|
||||
limit: int = 100,
|
||||
token: str = Depends(oauth2_scheme),
|
||||
):
|
||||
if not valid_token(token):
|
||||
@ -168,6 +169,8 @@ async def get_card_ratings(
|
||||
)
|
||||
all_ratings = all_ratings.where(PitchingCardRatings.pitchingcard << set_cards)
|
||||
|
||||
all_ratings = all_ratings.limit(max(0, min(limit, 500)))
|
||||
|
||||
if csv:
|
||||
return_val = query_to_csv(all_ratings)
|
||||
return Response(content=return_val, media_type="text/csv")
|
||||
@ -231,10 +234,10 @@ def get_scouting_dfs(cardset_id: list = None):
|
||||
|
||||
series_list = [
|
||||
pd.Series(
|
||||
dict([(x.player.player_id, x.range) for x in positions]), name=f"Range P"
|
||||
dict([(x.player.player_id, x.range) for x in positions]), name="Range P"
|
||||
),
|
||||
pd.Series(
|
||||
dict([(x.player.player_id, x.error) for x in positions]), name=f"Error P"
|
||||
dict([(x.player.player_id, x.error) for x in positions]), name="Error P"
|
||||
),
|
||||
]
|
||||
logging.debug(f"series_list: {series_list}")
|
||||
@ -274,7 +277,7 @@ async def post_calc_scouting(token: str = Depends(oauth2_scheme)):
|
||||
status_code=401, detail="You are not authorized to calculate card ratings."
|
||||
)
|
||||
|
||||
logging.warning(f"Re-calculating pitching ratings\n\n")
|
||||
logging.warning("Re-calculating pitching ratings\n\n")
|
||||
|
||||
output = get_scouting_dfs()
|
||||
first = ["player_id", "player_name", "cardset_name", "rarity", "hand", "variant"]
|
||||
@ -310,7 +313,7 @@ async def post_calc_basic(token: str = Depends(oauth2_scheme)):
|
||||
status_code=401, detail="You are not authorized to calculate basic ratings."
|
||||
)
|
||||
|
||||
logging.warning(f"Re-calculating basic pitching ratings\n\n")
|
||||
logging.warning("Re-calculating basic pitching ratings\n\n")
|
||||
|
||||
raw_data = get_scouting_dfs()
|
||||
logging.debug(f"output: {raw_data}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user