Merge branch 'main' into issue/136-feat-add-limit-pagination-to-pitchingcardratings-e
This commit is contained in:
commit
cc98a3b368
@ -73,6 +73,7 @@ async def get_players(
|
|||||||
key_mlbam: list = Query(default=None),
|
key_mlbam: list = Query(default=None),
|
||||||
offense_col: list = Query(default=None),
|
offense_col: list = Query(default=None),
|
||||||
csv: Optional[bool] = False,
|
csv: Optional[bool] = False,
|
||||||
|
limit: int = 100,
|
||||||
):
|
):
|
||||||
all_players = MlbPlayer.select().order_by(MlbPlayer.id)
|
all_players = MlbPlayer.select().order_by(MlbPlayer.id)
|
||||||
|
|
||||||
@ -101,6 +102,8 @@ async def get_players(
|
|||||||
if offense_col is not None:
|
if offense_col is not None:
|
||||||
all_players = all_players.where(MlbPlayer.offense_col << offense_col)
|
all_players = all_players.where(MlbPlayer.offense_col << offense_col)
|
||||||
|
|
||||||
|
all_players = all_players.limit(max(0, min(limit, 500)))
|
||||||
|
|
||||||
if csv:
|
if csv:
|
||||||
return_val = query_to_csv(all_players)
|
return_val = query_to_csv(all_players)
|
||||||
return Response(content=return_val, media_type="text/csv")
|
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)
|
| (MlbPlayer.key_bbref == player.key_bbref)
|
||||||
)
|
)
|
||||||
if dupes.count() > 0:
|
if dupes.count() > 0:
|
||||||
logging.info(f"POST /mlbplayers/one - dupes found:")
|
logging.info("POST /mlbplayers/one - dupes found:")
|
||||||
for x in dupes:
|
for x in dupes:
|
||||||
logging.info(f"{x}")
|
logging.info(f"{x}")
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user