feat: add limit/pagination to cardpositions endpoint (#142) #168
@ -51,6 +51,7 @@ async def get_card_positions(
|
||||
cardset_id: list = Query(default=None),
|
||||
short_output: Optional[bool] = False,
|
||||
sort: Optional[str] = "innings-desc",
|
||||
limit: int = 100,
|
||||
):
|
||||
all_pos = (
|
||||
CardPosition.select()
|
||||
@ -86,6 +87,9 @@ async def get_card_positions(
|
||||
elif sort == "range-asc":
|
||||
all_pos = all_pos.order_by(CardPosition.range, CardPosition.id)
|
||||
|
||||
limit = max(0, min(limit, 500))
|
||||
all_pos = all_pos.limit(limit)
|
||||
|
||||
return_val = {
|
||||
"count": all_pos.count(),
|
||||
"positions": [model_to_dict(x, recurse=not short_output) for x in all_pos],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user