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
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:
1 parent
383b63bc0e
commit
52d2ce25c9
10 files changed
+707
-340
No files matched your search
@@ -320,11 +320,11 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
|
||||
<template data-row-fields>
|
||||
@pageMonitorFields(e, PageMonitorOption{})
|
||||
</template>
|
||||
<ul id="page-monitors" class="mb-4 divide-y divide-rule border-y border-rule text-sm">
|
||||
<ul id="page-monitors" class="mb-4 divide-y divide-rule border-y border-rule text-sm" data-page-size={ strconv.Itoa(monitorPageSize) }>
|
||||
for _, m := range e.Monitors {
|
||||
<li data-row class="grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-1.5 py-2">
|
||||
<input type="checkbox" data-field="include" checked?={ m.Included } class="accent-ink" aria-label={ m.Name }/>
|
||||
<span class="flex flex-wrap items-baseline gap-x-2">
|
||||
<span data-filter-text class="flex flex-wrap items-baseline gap-x-2">
|
||||
<span>{ m.Name }</span>
|
||||
if m.MonitorGroupPath != "" {
|
||||
<span class="font-mono text-xs text-muted">{ m.MonitorGroupPath }</span>
|
||||
@@ -339,6 +339,15 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
if len(e.Monitors) > monitorPageSize {
|
||||
// All rows stay in the form, as saving replaces the page's
|
||||
// monitors; the pager only shows them a page at a time.
|
||||
<nav data-row-pager="#page-monitors" class="-mt-2 mb-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm" aria-label={ i18n.T(ctx, "pager.label") }>
|
||||
<button type="button" data-row-page="prev" class="text-muted hover:text-ink disabled:opacity-40">← { i18n.T(ctx, "pager.previous") }</button>
|
||||
<span data-row-page-status data-template={ i18n.T(ctx, "pages.monitors_range") } class="text-xs text-muted"></span>
|
||||
<button type="button" data-row-page="next" class="text-muted hover:text-ink disabled:opacity-40">{ i18n.T(ctx, "pager.next") } →</button>
|
||||
</nav>
|
||||
}
|
||||
@submit(i18n.T(ctx, "common.save"))
|
||||
</form>
|
||||
</section>
|
||||
@@ -416,16 +425,33 @@ templ verifyButton(pageID, label string) {
|
||||
// offers to filter them.
|
||||
const monitorFilterFrom = 15
|
||||
|
||||
// monitorPageSize is how many monitors the page editor shows at a time.
|
||||
const monitorPageSize = 50
|
||||
|
||||
// pageMonitorFields are the group and label of m on the page.
|
||||
templ pageMonitorFields(e PageEditor, m PageMonitorOption) {
|
||||
<span data-row-extra></span>
|
||||
<span class="flex gap-2">
|
||||
<select data-field="group_id" data-nullable aria-label={ i18n.T(ctx, "pages.group") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink">
|
||||
<option value="">{ i18n.T(ctx, "pages.no_group") }</option>
|
||||
for _, opt := range e.Groups {
|
||||
<option value={ opt.ID } selected?={ opt.ID == m.GroupID }>{ opt.Label }</option>
|
||||
}
|
||||
</select>
|
||||
if m.ID == "" {
|
||||
<select data-field="group_id" data-nullable aria-label={ i18n.T(ctx, "pages.group") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink">
|
||||
<option value="">{ i18n.T(ctx, "pages.no_group") }</option>
|
||||
for _, opt := range e.Groups {
|
||||
<option value={ opt.ID }>{ opt.Label }</option>
|
||||
}
|
||||
</select>
|
||||
} else {
|
||||
// With thousands of monitors and hundreds of groups the options of
|
||||
// every row would make the page tens of megabytes: rows carry their
|
||||
// group only and get the others from the template when shown.
|
||||
<select data-field="group_id" data-nullable data-lazy-options aria-label={ i18n.T(ctx, "pages.group") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink">
|
||||
<option value="">{ i18n.T(ctx, "pages.no_group") }</option>
|
||||
for _, opt := range e.Groups {
|
||||
if opt.ID == m.GroupID {
|
||||
<option value={ opt.ID } selected>{ opt.Label }</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
}
|
||||
<input data-field="label" value={ m.Label } placeholder={ i18n.T(ctx, "pages.label") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink"/>
|
||||
</span>
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user