Merge pull request 'feat: add limit/pagination to events endpoint (#147)' (#156) from issue/147-feat-add-limit-pagination-to-events-endpoint into main
This commit is contained in:
commit
f2e10bcf2f
@ -26,7 +26,7 @@ class EventModel(pydantic.BaseModel):
|
||||
@router.get('')
|
||||
async def v1_events_get(
|
||||
name: Optional[str] = None, in_desc: Optional[str] = None, active: Optional[bool] = None,
|
||||
csv: Optional[bool] = None):
|
||||
csv: Optional[bool] = None, limit: Optional[int] = 100):
|
||||
all_events = Event.select().order_by(Event.id)
|
||||
|
||||
if name is not None:
|
||||
@ -39,6 +39,8 @@ async def v1_events_get(
|
||||
if active is not None:
|
||||
all_events = all_events.where(Event.active == active)
|
||||
|
||||
all_events = all_events.limit(max(0, min(limit, 500)))
|
||||
|
||||
if csv:
|
||||
data_list = [['id', 'name', 'short_desc', 'long_desc', 'url', 'thumbnail', 'active']]
|
||||
for line in all_events:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user