feat: page long and truncated lists
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
This commit is contained in:
1 parent
98fb5d3a82
commit
d7c5cd711e
63 files changed
+5427
-3041
No files matched your search
@@ -12,12 +12,22 @@ FROM check_results
|
||||
WHERE org_id = $1 AND time > now() - interval '1 day'
|
||||
ORDER BY monitor_id, region, time DESC;
|
||||
|
||||
-- name: RecentResults :many
|
||||
SELECT time, region, ok, latency_ms, status_code, error, checker_id
|
||||
-- name: ListResults :many
|
||||
-- A monitor's results newest first, a page from a keyset cursor (see
|
||||
-- paging.go) whose string key is region and checker.
|
||||
SELECT time, region, ok, latency_ms, status_code, error, checker_id,
|
||||
(region || '|' || checker_id::text)::text AS position
|
||||
FROM check_results
|
||||
WHERE org_id = $1 AND monitor_id = $2 AND time > $3
|
||||
ORDER BY time DESC
|
||||
LIMIT 500;
|
||||
WHERE org_id = sqlc.arg(org_id) AND monitor_id = sqlc.arg(monitor_id)
|
||||
AND (sqlc.narg(after_t)::timestamptz IS NULL
|
||||
OR time <= sqlc.narg(after_t) AND (time, region || '|' || checker_id::text) < (sqlc.narg(after_t), sqlc.narg(after_s)::text))
|
||||
AND (sqlc.narg(before_t)::timestamptz IS NULL
|
||||
OR time >= sqlc.narg(before_t) AND (time, region || '|' || checker_id::text) > (sqlc.narg(before_t), sqlc.narg(before_s)::text))
|
||||
ORDER BY
|
||||
CASE WHEN sqlc.narg(before_t)::timestamptz IS NULL THEN time END DESC,
|
||||
CASE WHEN sqlc.narg(before_t)::timestamptz IS NULL THEN region || '|' || checker_id::text END DESC,
|
||||
time, region || '|' || checker_id::text
|
||||
LIMIT sqlc.arg(max_rows);
|
||||
|
||||
-- name: UptimeSince :many
|
||||
-- Uptime per monitor from the hourly aggregate, including the not yet
|
||||
@@ -130,12 +140,20 @@ WHERE org_id = $1 AND time >= $2
|
||||
GROUP BY 1, 2;
|
||||
|
||||
-- name: ResultsByChecker :many
|
||||
-- The organization's latest results run by one checker instance.
|
||||
-- The organization's results run by one checker instance, newest first, a
|
||||
-- page from a keyset cursor whose string key is monitor and region.
|
||||
SELECT r.time, r.monitor_id, r.region, r.ok, r.latency_ms, r.status_code, r.error
|
||||
FROM check_results r
|
||||
WHERE r.org_id = $1 AND r.checker_id = sqlc.arg(checker_id) AND r.time > now() - interval '1 day'
|
||||
ORDER BY r.time DESC
|
||||
LIMIT 50;
|
||||
WHERE r.org_id = sqlc.arg(org_id) AND r.checker_id = sqlc.arg(checker_id)
|
||||
AND (sqlc.narg(after_t)::timestamptz IS NULL
|
||||
OR r.time <= sqlc.narg(after_t) AND (r.time, r.monitor_id::text || '|' || r.region) < (sqlc.narg(after_t), sqlc.narg(after_s)::text))
|
||||
AND (sqlc.narg(before_t)::timestamptz IS NULL
|
||||
OR r.time >= sqlc.narg(before_t) AND (r.time, r.monitor_id::text || '|' || r.region) > (sqlc.narg(before_t), sqlc.narg(before_s)::text))
|
||||
ORDER BY
|
||||
CASE WHEN sqlc.narg(before_t)::timestamptz IS NULL THEN r.time END DESC,
|
||||
CASE WHEN sqlc.narg(before_t)::timestamptz IS NULL THEN r.monitor_id::text || '|' || r.region END DESC,
|
||||
r.time, r.monitor_id::text || '|' || r.region
|
||||
LIMIT sqlc.arg(max_rows);
|
||||
|
||||
-- name: CheckerStats :one
|
||||
-- How much one instance checked for the organization in the last hour.
|
||||
|
||||
Reference in new issue
Block a user