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

+49 -13
View File
@@ -150,6 +150,37 @@ func (q *Queries) CreateStatusPageGroup(ctx context.Context, arg CreateStatusPag
return i, err
}
const createStatusPageGroups = `-- name: CreateStatusPageGroups :exec
INSERT INTO status_page_groups (id, page_id, org_id, parent_id, name, position)
SELECT v.id, $1, $2, nullif(v.parent_id, '00000000-0000-0000-0000-000000000000'::uuid), v.name, v.position
FROM (SELECT unnest($3::uuid[]) AS id, unnest($4::uuid[]) AS parent_id,
unnest($5::text[]) AS name, unnest($6::int[]) AS position) AS v
`
type CreateStatusPageGroupsParams struct {
PageID uuid.UUID
OrgID uuid.UUID
Ids []uuid.UUID
ParentIds []uuid.UUID
Names []string
Positions []int32
}
// 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.
func (q *Queries) CreateStatusPageGroups(ctx context.Context, arg CreateStatusPageGroupsParams) error {
_, err := q.db.Exec(ctx, createStatusPageGroups,
arg.PageID,
arg.OrgID,
arg.Ids,
arg.ParentIds,
arg.Names,
arg.Positions,
)
return err
}
const deleteStatusPage = `-- name: DeleteStatusPage :execrows
DELETE FROM status_pages WHERE id = $1
`
@@ -563,24 +594,29 @@ func (q *Queries) SetStatusPageDomain(ctx context.Context, arg SetStatusPageDoma
return i, err
}
const setStatusPageMonitorGroup = `-- name: SetStatusPageMonitorGroup :exec
UPDATE status_page_monitors SET group_id = $3, section = $4
WHERE page_id = $1 AND monitor_id = $2
const setStatusPageMonitorGroups = `-- name: SetStatusPageMonitorGroups :exec
UPDATE status_page_monitors spm
SET group_id = nullif(v.group_id, '00000000-0000-0000-0000-000000000000'::uuid), section = v.section
FROM (SELECT unnest($2::uuid[]) AS monitor_id, unnest($3::uuid[]) AS group_id,
unnest($4::text[]) AS section) AS v
WHERE spm.page_id = $1 AND spm.monitor_id = v.monitor_id
`
type SetStatusPageMonitorGroupParams struct {
PageID uuid.UUID
MonitorID uuid.UUID
GroupID *uuid.UUID
Section string
type SetStatusPageMonitorGroupsParams struct {
PageID uuid.UUID
MonitorIds []uuid.UUID
GroupIds []uuid.UUID
Sections []string
}
func (q *Queries) SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error {
_, err := q.db.Exec(ctx, setStatusPageMonitorGroup,
// Files many monitors of a page at once; a nil group id (all zeros) files
// a monitor under none.
func (q *Queries) SetStatusPageMonitorGroups(ctx context.Context, arg SetStatusPageMonitorGroupsParams) error {
_, err := q.db.Exec(ctx, setStatusPageMonitorGroups,
arg.PageID,
arg.MonitorID,
arg.GroupID,
arg.Section,
arg.MonitorIds,
arg.GroupIds,
arg.Sections,
)
return err
}