feat: add limit/pagination to gauntletrewards endpoint (#145) #165
@ -30,6 +30,7 @@ async def v1_gauntletreward_get(
|
||||
reward_id: list = Query(default=None),
|
||||
win_num: Optional[int] = None,
|
||||
loss_max: Optional[int] = None,
|
||||
limit: int = 100,
|
||||
):
|
||||
all_rewards = GauntletReward.select().order_by(GauntletReward.id)
|
||||
|
||||
@ -46,6 +47,9 @@ async def v1_gauntletreward_get(
|
||||
|
||||
all_rewards = all_rewards.order_by(-GauntletReward.loss_max, GauntletReward.win_num)
|
||||
|
||||
limit = max(0, min(limit, 500))
|
||||
all_rewards = all_rewards.limit(limit)
|
||||
|
||||
return_val = {"count": all_rewards.count(), "rewards": []}
|
||||
for x in all_rewards:
|
||||
return_val["rewards"].append(model_to_dict(x))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user