feat: add limit/pagination to mlbplayers endpoint (#141)
Closes #141 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6a217f97ee
commit
9391591263
@ -73,6 +73,7 @@ async def get_players(
|
||||
key_mlbam: list = Query(default=None),
|
||||
offense_col: list = Query(default=None),
|
||||
csv: Optional[bool] = False,
|
||||
limit: int = 100,
|
||||
):
|
||||
all_players = MlbPlayer.select().order_by(MlbPlayer.id)
|
||||
|
||||
@ -101,6 +102,8 @@ async def get_players(
|
||||
if offense_col is not None:
|
||||
all_players = all_players.where(MlbPlayer.offense_col << offense_col)
|
||||
|
||||
all_players = all_players.limit(max(0, min(limit, 500)))
|
||||
|
||||
if csv:
|
||||
return_val = query_to_csv(all_players)
|
||||
return Response(content=return_val, media_type="text/csv")
|
||||
@ -222,7 +225,7 @@ async def post_one_player(player: PlayerModel, token: str = Depends(oauth2_schem
|
||||
| (MlbPlayer.key_bbref == player.key_bbref)
|
||||
)
|
||||
if dupes.count() > 0:
|
||||
logging.info(f"POST /mlbplayers/one - dupes found:")
|
||||
logging.info("POST /mlbplayers/one - dupes found:")
|
||||
for x in dupes:
|
||||
logging.info(f"{x}")
|
||||
raise HTTPException(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user