From 2f5694272183bb22e0485c7c2c445ba4296b0d4c Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Tue, 24 Mar 2026 04:02:46 -0500 Subject: [PATCH] feat: add limit/pagination to pitchingcardratings endpoint (#136) Closes #136 Co-Authored-By: Claude Sonnet 4.6 --- app/routers_v2/pitchingcardratings.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/routers_v2/pitchingcardratings.py b/app/routers_v2/pitchingcardratings.py index fcff541..294ef14 100644 --- a/app/routers_v2/pitchingcardratings.py +++ b/app/routers_v2/pitchingcardratings.py @@ -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}")