feat: add limit/pagination to events endpoint (#147)

Closes #147

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-24 01:32:19 -05:00
parent 6a217f97ee
commit 0f884a3516

View File

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