feat: page long and truncated lists #117

Merged
Sebi merged 2 commits from feat/paging into main 2026-11-22 20:46:18 +00:00
Owner

Stacked on #115.

Replaces fixed LIMITs (information was lost) and unbounded lists with keyset paging: the cursor is the sort key plus an ID, so pages neither skip nor repeat items while others are added.

API — every list returns at most 100 items (limit up to 500) plus next_cursor/prev_cursor; pass them as after/before. Explained once in the API reference intro; paged endpoints say so. Bad cursors → 422 invalid_cursor, bad limits → 422 invalid_limit.

Console — server-rendered Newer/Older (or Previous/Next, Earlier/Later) links and To the start; works without JavaScript, pages are linkable.

List Before Now
Incidents 200 paged; monitor_id / ?monitor= filter
A monitor's incidents (detail) 20 latest 10 + All incidents of this monitor
A monitor's results last 50 of 500 in 24 h latest 50 + new paged page / API GET /org/monitors/:id/results, back to the end of retention
Evidence 100 paged API; detail lists the latest 20; results link their evidence for the shown span
A checker's results 50 in 24 h paged (live refresh only on the first page)
Audit logs (org, account, platform) timestamp cursor could skip equal times (time, id) cursor, both directions; next_before replaced by the common cursors
Admin status pages / organizations 500 paged, on their own admin pages /admin/status-pages, /admin/orgs
Members, maintenance windows, firing Alertmanager alerts, monitors API unbounded paged
Dashboard everything each group shows 50 of its own monitors + Show all N → paged group view (/?group=…, also for ungrouped); search by name or target

Lists filtered by group permissions after reading (monitors API, maintenance, checker results) may hold fewer items on a page; documented. Not paged: pending invitations (expire), regions/agents, roles, tokens, channels — short lists, mostly used in forms.

Also: fix(datapolicy) — running TimescaleDB jobs report -infinity as next start, which broke the storage overview and made its test flaky.

Tests: paginate/pageSlice unit tests (forward, backward, ends); API paging through monitors and incidents with identical start times (nothing skipped or repeated, same result both directions), filters, invalid input, console links; dashboard with 55 monitors in a group (cap, show-all link, paged group view, search, ungrouped view). The store guard that check-result queries filter by org now also accepts named parameters.

Closes #116

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

Stacked on #115. Replaces fixed `LIMIT`s (information was lost) and unbounded lists with **keyset paging**: the cursor is the sort key plus an ID, so pages neither skip nor repeat items while others are added. **API** — every list returns at most 100 items (`limit` up to 500) plus `next_cursor`/`prev_cursor`; pass them as `after`/`before`. Explained once in the API reference intro; paged endpoints say so. Bad cursors → `422 invalid_cursor`, bad limits → `422 invalid_limit`. **Console** — server-rendered Newer/Older (or Previous/Next, Earlier/Later) links and *To the start*; works without JavaScript, pages are linkable. | List | Before | Now | | --- | --- | --- | | Incidents | 200 | paged; `monitor_id` / `?monitor=` filter | | A monitor's incidents (detail) | 20 | latest 10 + *All incidents of this monitor* | | A monitor's results | last 50 of 500 in 24 h | latest 50 + new paged page / API `GET /org/monitors/:id/results`, back to the end of retention | | Evidence | 100 | paged API; detail lists the latest 20; results link their evidence for the shown span | | A checker's results | 50 in 24 h | paged (live refresh only on the first page) | | Audit logs (org, account, platform) | timestamp cursor could skip equal times | (time, id) cursor, both directions; `next_before` replaced by the common cursors | | Admin status pages / organizations | 500 | paged, on their own admin pages `/admin/status-pages`, `/admin/orgs` | | Members, maintenance windows, firing Alertmanager alerts, monitors API | unbounded | paged | | Dashboard | everything | each group shows 50 of its own monitors + *Show all N* → paged group view (`/?group=…`, also for ungrouped); search by name or target | Lists filtered by group permissions after reading (monitors API, maintenance, checker results) may hold fewer items on a page; documented. Not paged: pending invitations (expire), regions/agents, roles, tokens, channels — short lists, mostly used in forms. Also: `fix(datapolicy)` — running TimescaleDB jobs report `-infinity` as next start, which broke the storage overview and made its test flaky. **Tests:** paginate/pageSlice unit tests (forward, backward, ends); API paging through monitors and incidents with identical start times (nothing skipped or repeated, same result both directions), filters, invalid input, console links; dashboard with 55 monitors in a group (cap, show-all link, paged group view, search, ungrouped view). The store guard that check-result queries filter by org now also accepts named parameters. Closes #116 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added this to the M12 Self-service signup & limits milestone 2026-11-22 20:40:57 +00:00
Sebi changed target branch from feat/org-limits to main 2026-11-22 20:45:12 +00:00
Sebi added 2 commits 2026-11-22 20:45:13 +00:00
A running job reports -infinity as its next start, which failed the
storage overview and, intermittently, its test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
feat: page long and truncated lists
ci / image (pull_request) Successful in 3m18s
ci / build (pull_request) Successful in 8m38s
ci / test (pull_request) Successful in 12m6s
ci / lint (pull_request) Successful in 15m0s
d7c5cd711e
Lists that were cut off by a fixed LIMIT, or could grow without bound,
are paged by keyset: the cursor holds the sort key and an ID, so pages
neither skip nor repeat items as others are added. The audit logs had a
timestamp-only cursor that could skip entries with equal times.

The API returns at most 100 items per list (limit takes up to 500) with
next_cursor and prev_cursor, passed back as after and before. The
console shows Newer/Older (or Previous/Next) links and To the start,
without JavaScript.

Paged: incidents (optionally of one monitor), a monitor's results and
evidence, a checker's results, the audit logs, members, maintenance
windows, firing Alertmanager alerts, the monitors API and the admin
lists of status pages and organizations, which move to their own admin
pages. A monitor's page shows its latest incidents and results and links
to all of them. The dashboard caps every group at 50 of its own monitors
with a link to a paged view of the group, and gains a search by name or
target. Lists filtered by permission after reading may show fewer items
on a page.

Closes #116

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit d644312f25 into main 2026-11-22 20:46:18 +00:00
Sebi deleted branch feat/paging 2026-11-22 20:46:20 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#117