perf(statuspages): page the monitor list and batch the group import
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m59s
ci / test (pull_request) Successful in 12m44s
ci / build (pull_request) Successful in 18m14s
ci / image (pull_request) Canceled after 1m1s

With thousands of monitors on a status page the editor was tens of
megabytes, as every row carried the options of all groups, and
importing the monitor groups updated each monitor in its own statement.

- The monitors of the editor are shown 50 at a time. All rows stay in
  the form, as saving replaces the page's monitors.
- Rows carry their own group only and get the other options from the
  row template once shown or focused.
- The filter matches a monitor's name and group path only, no longer
  the names of the groups in its select.
- The import creates the groups one nesting level at a time and files
  all monitors in one statement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-26 23:38:08 +01:00
1 parent 383b63bc0e
commit 52d2ce25c9
10 files changed
+707 -340

No files matched your search

+17 -3
View File
@@ -100,9 +100,23 @@ DELETE FROM status_page_monitors WHERE page_id = $1;
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, group_id, label, position)
VALUES ($1, $2, $3, $4, $5, $6, $7);
-- name: SetStatusPageMonitorGroup :exec
UPDATE status_page_monitors SET group_id = $3, section = $4
WHERE page_id = $1 AND monitor_id = $2;
-- name: SetStatusPageMonitorGroups :exec
-- Files many monitors of a page at once; a nil group id (all zeros) files
-- a monitor under none.
UPDATE status_page_monitors spm
SET group_id = nullif(v.group_id, '00000000-0000-0000-0000-000000000000'::uuid), section = v.section
FROM (SELECT unnest(sqlc.arg(monitor_ids)::uuid[]) AS monitor_id, unnest(sqlc.arg(group_ids)::uuid[]) AS group_id,
unnest(sqlc.arg(sections)::text[]) AS section) AS v
WHERE spm.page_id = sqlc.arg(page_id) AND spm.monitor_id = v.monitor_id;
-- name: CreateStatusPageGroups :exec
-- Creates many groups of a page at once, with ids the caller chose. Parents
-- must exist before their children are created; a nil parent id (all
-- zeros) means none.
INSERT INTO status_page_groups (id, page_id, org_id, parent_id, name, position)
SELECT v.id, sqlc.arg(page_id), sqlc.arg(org_id), nullif(v.parent_id, '00000000-0000-0000-0000-000000000000'::uuid), v.name, v.position
FROM (SELECT unnest(sqlc.arg(ids)::uuid[]) AS id, unnest(sqlc.arg(parent_ids)::uuid[]) AS parent_id,
unnest(sqlc.arg(names)::text[]) AS name, unnest(sqlc.arg(positions)::int[]) AS position) AS v;
-- name: ListStatusPageGroups :many
SELECT * FROM status_page_groups