Paginate the events list endpoint #40

Open
opened 2026-10-03 19:44:38 +00:00 by jalenluorion · 0 comments
Member

Goal
Explore should load fast on a phone. /api/events/ returns every event at once (about 1.35 MB), and it grows with each source we add.

Current state

  • get_all_events in api/app/api/events.py (GET /api/events/, @public, commented "should only be used for testing purposes"). It supports term, tags, date, event_type but has no limit or date window.
  • Web fetches everything once in web/src/context/UserContext.tsx (fetchEvents), and web/src/app/components/SearchResultSidebar.tsx filters by date, type and text on the client, then paginates 20 per page.
  • Client search also checks description, which the endpoint never returns, so that part does nothing.

Scope

  • Add a date window (start, end; default now to now + N weeks) and pagination (limit plus cursor or page) to /api/events/. Return {events, next_cursor/total}.
  • Move text search, type and date filters server side (the endpoint already supports most of them).
  • Add an index if the query plan needs one (events.start_datetime), via an alembic migration.
  • Update Explore to request pages (infinite scroll or Next/Previous) instead of loading everything.
  • Find and update every other caller of /events/.
  • API tests in api/tests/api/ for the window, page size and filters.

Done when

  • The default Explore request is under 100 KB.
  • Filters and paging give the same results as before, just faster.

Notes
Coordinate with the bug "Explore shows no events by default", which changes what the endpoint returns and who can call it. Land that first or in the same PR. Explore v2 builds on this.

**Goal** Explore should load fast on a phone. `/api/events/` returns every event at once (about 1.35 MB), and it grows with each source we add. **Current state** - `get_all_events` in `api/app/api/events.py` (`GET /api/events/`, `@public`, commented "should only be used for testing purposes"). It supports `term`, `tags`, `date`, `event_type` but has no limit or date window. - Web fetches everything once in `web/src/context/UserContext.tsx` (`fetchEvents`), and `web/src/app/components/SearchResultSidebar.tsx` filters by date, type and text on the client, then paginates 20 per page. - Client search also checks `description`, which the endpoint never returns, so that part does nothing. **Scope** - [ ] Add a date window (`start`, `end`; default now to now + N weeks) and pagination (`limit` plus `cursor` or `page`) to `/api/events/`. Return `{events, next_cursor/total}`. - [ ] Move text search, type and date filters server side (the endpoint already supports most of them). - [ ] Add an index if the query plan needs one (`events.start_datetime`), via an alembic migration. - [ ] Update Explore to request pages (infinite scroll or Next/Previous) instead of loading everything. - [ ] Find and update every other caller of `/events/`. - [ ] API tests in `api/tests/api/` for the window, page size and filters. **Done when** - [ ] The default Explore request is under 100 KB. - [ ] Filters and paging give the same results as before, just faster. **Notes** Coordinate with the bug "Explore shows no events by default", which changes what the endpoint returns and who can call it. Land that first or in the same PR. Explore v2 builds on this.
jalenluorion added this to the Phase 1 milestone 2026-10-03 19:44:38 +00:00
jalenluorion added this to the CMUCal project 2026-10-03 19:45:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/cal#40
No description provided.