The admin panel lists every published status page, and every suspended page, organization or account, with the organization and owner behind it, searchable by title, address, organization or email. Each can be suspended with a reason, reinstated, or deleted. A suspended page is not served; status page servers drop it when they next ask. A suspended organization's monitors leave the schedule, its pages go offline, heartbeat pings and Alertmanager webhooks are no longer recorded, and its members and API tokens get 403 org_suspended; the console explains why. Reinstating restarts heartbeat waits so they do not fire at once. A suspended account is signed out everywhere and can neither sign in nor use its tokens; only someone who knows the password learns of the suspension. Platform admins cannot be suspended or deleted. Account deletion shares its logic with the GDPR erasure, including the refusal while the account owns shared organizations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
92 lines
2.5 KiB
Go
92 lines
2.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: heartbeats.sql
|
|
|
|
package store
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const heartbeatMonitor = `-- name: HeartbeatMonitor :one
|
|
SELECT m.id, m.org_id, m.interval_seconds, m.confirmations, coalesce(m.enabled AND o.suspended_at IS NULL, false)::boolean AS enabled
|
|
FROM monitors m JOIN orgs o ON o.id = m.org_id
|
|
WHERE m.type = 'heartbeat' AND m.target = $1
|
|
`
|
|
|
|
type HeartbeatMonitorRow struct {
|
|
ID uuid.UUID
|
|
OrgID uuid.UUID
|
|
IntervalSeconds int32
|
|
Confirmations int32
|
|
Enabled bool
|
|
}
|
|
|
|
// System scope: the monitor a ping token belongs to.
|
|
func (q *Queries) HeartbeatMonitor(ctx context.Context, target string) (HeartbeatMonitorRow, error) {
|
|
row := q.db.QueryRow(ctx, heartbeatMonitor, target)
|
|
var i HeartbeatMonitorRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.IntervalSeconds,
|
|
&i.Confirmations,
|
|
&i.Enabled,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const heartbeatsDue = `-- name: HeartbeatsDue :many
|
|
SELECT m.id, m.org_id, m.interval_seconds, m.confirmations,
|
|
coalesce((m.config->>'grace_seconds')::integer, 0)::integer AS grace_seconds,
|
|
greatest(m.updated_at, coalesce((SELECT max(r.time) FROM check_results r
|
|
WHERE r.org_id = m.org_id AND r.monitor_id = m.id AND r.time > now() - interval '3 days'), m.updated_at))::timestamptz AS waiting_since
|
|
FROM monitors m
|
|
JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL
|
|
WHERE m.type = 'heartbeat' AND m.enabled
|
|
`
|
|
|
|
type HeartbeatsDueRow struct {
|
|
ID uuid.UUID
|
|
OrgID uuid.UUID
|
|
IntervalSeconds int32
|
|
Confirmations int32
|
|
GraceSeconds int32
|
|
WaitingSince time.Time
|
|
}
|
|
|
|
// System scope: enabled heartbeat monitors with their grace period and
|
|
// since when they are being waited for: the latest result, or the last
|
|
// change of the monitor, which covers new and re-enabled ones. The result
|
|
// lookup is bounded because the longest interval plus grace is two days.
|
|
func (q *Queries) HeartbeatsDue(ctx context.Context) ([]HeartbeatsDueRow, error) {
|
|
rows, err := q.db.Query(ctx, heartbeatsDue)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []HeartbeatsDueRow{}
|
|
for rows.Next() {
|
|
var i HeartbeatsDueRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.OrgID,
|
|
&i.IntervalSeconds,
|
|
&i.Confirmations,
|
|
&i.GraceSeconds,
|
|
&i.WaitingSince,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|