feat: incident updates with a status, public or internal
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m54s
ci / test (pull_request) Successful in 12m15s
ci / build (pull_request) Successful in 11m0s
ci / image (pull_request) Successful in 4m23s

Outages open and close with their monitor; now people can say what is
going on. An incident gets an optional title and updates, each with a
status (investigating, identified, monitoring, resolved) and a Markdown
message, shown on status pages or kept as an internal note. The incident
shows the latest update's status, resolved once its monitor recovered.

The console lists title and status and has a page per incident with its
timeline (outage, updates, recovery) and, for incidents.write in the
monitor's group, forms to post updates and set the title. Status pages
show title, status and public updates. API: GET/PATCH
/org/incidents/:id, POST and DELETE /org/incidents/:id/updates; the
incident list carries title and status; the organization export
includes the updates.

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-23 23:38:07 +01:00
1 parent 6f0cf59406
commit 43a04e99b1
27 files changed
+2753 -908

No files matched your search

+5 -1
View File
@@ -66,10 +66,14 @@ FROM role_assignments ra JOIN roles r ON r.id = ra.role_id
WHERE ra.org_id = $1;
-- name: OrgIncidentsExport :many
SELECT i.id, i.monitor_id, m.name AS monitor, i.started_at, i.resolved_at, i.cause
SELECT i.id, i.monitor_id, m.name AS monitor, i.started_at, i.resolved_at, i.cause, i.title, i.status
FROM incidents i LEFT JOIN monitors m ON m.id = i.monitor_id
WHERE i.org_id = $1 ORDER BY i.started_at;
-- name: OrgIncidentUpdatesExport :many
SELECT incident_id, status, message, public, created_at FROM incident_updates
WHERE org_id = $1 ORDER BY created_at;
-- name: OrgAuditExport :many
SELECT e.time, e.action, coalesce(u.email::text, '')::text AS actor, e.target_id, e.details, e.status,
coalesce(host(e.ip), '')::text AS ip
+36
View File
@@ -96,3 +96,39 @@ LIMIT 50;
-- Incidents overlapping the time since $1, for SLA calculation.
SELECT monitor_id, started_at, resolved_at FROM incidents
WHERE resolved_at IS NULL OR resolved_at > $1;
-- name: GetIncident :one
SELECT i.*, m.name AS monitor_name, m.group_id AS monitor_group_id
FROM incidents i JOIN monitors m ON m.id = i.monitor_id
WHERE i.id = $1;
-- name: SetIncidentTitle :execrows
UPDATE incidents SET title = sqlc.arg(title) WHERE id = sqlc.arg(id);
-- name: AddIncidentUpdate :one
INSERT INTO incident_updates (org_id, incident_id, status, message, public, author_id)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *;
-- name: DeleteIncidentUpdate :execrows
DELETE FROM incident_updates WHERE id = sqlc.arg(id) AND incident_id = sqlc.arg(incident_id);
-- name: RefreshIncidentStatus :exec
-- The incident shows the status of its latest update.
UPDATE incidents SET status = (
SELECT u.status FROM incident_updates u WHERE u.incident_id = incidents.id
ORDER BY u.created_at DESC, u.id DESC LIMIT 1
) WHERE incidents.id = $1;
-- name: ListIncidentUpdates :many
-- Newest first, with the author's name.
SELECT u.*, coalesce(nullif(usr.display_name, ''), usr.email::text, '')::text AS author_name
FROM incident_updates u LEFT JOIN users usr ON usr.id = u.author_id
WHERE u.incident_id = $1
ORDER BY u.created_at DESC, u.id DESC;
-- name: PublicIncidentUpdates :many
-- The public updates of incidents shown on a status page, newest first.
SELECT incident_id, status, message, created_at FROM incident_updates
WHERE incident_id = ANY(sqlc.arg(ids)::uuid[]) AND public
ORDER BY created_at DESC, id DESC;