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

+7 -1
View File
@@ -90,6 +90,10 @@ type Querier interface {
CreateSSOProvider(ctx context.Context, arg CreateSSOProviderParams) (SsoProvider, error)
CreateStatusPage(ctx context.Context, arg CreateStatusPageParams) (StatusPage, error)
CreateStatusPageGroup(ctx context.Context, arg CreateStatusPageGroupParams) (StatusPageGroup, error)
// 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.
CreateStatusPageGroups(ctx context.Context, arg CreateStatusPageGroupsParams) error
CreateSupportTicket(ctx context.Context, arg CreateSupportTicketParams) (SupportTicket, error)
CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
DailyBuckets(ctx context.Context, arg DailyBucketsParams) ([]DailyBucketsRow, error)
@@ -395,7 +399,9 @@ type Querier interface {
SetPlatformSetting(ctx context.Context, arg SetPlatformSettingParams) error
// Changing the domain drops a previous verification and its checks.
SetStatusPageDomain(ctx context.Context, arg SetStatusPageDomainParams) (StatusPage, error)
SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPageMonitorGroupParams) error
// Files many monitors of a page at once; a nil group id (all zeros) files
// a monitor under none.
SetStatusPageMonitorGroups(ctx context.Context, arg SetStatusPageMonitorGroupsParams) error
SetSupportTicketStatus(ctx context.Context, arg SetSupportTicketStatusParams) (int64, error)
SetUserAdmin(ctx context.Context, arg SetUserAdminParams) (int64, error)
SetUserLocale(ctx context.Context, arg SetUserLocaleParams) error
+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
+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
}