Merge pull request 'feat: add limit/pagination to gauntletrewards endpoint (#145)' (#165) from issue/145-feat-add-limit-pagination-to-gauntletrewards-endpo into main

This commit is contained in:
cal 2026-03-24 12:12:32 +00:00
commit b14907d018

View File

@ -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))