Flag incidents that carry notes in the queue

A blue tag with the notebook icon and a count marks an incident with
working notes; a green one marks a note on what fixed it. Both let you
scan the queue for incidents that have more to say than their title,
without opening each one.

The incident list and detail JSON gain note_count and
resolution_note_count, counted in the same query that selects the
incident, so a list costs no extra request per row. The fields are
additive: terdut-tui and terdut-operator ignore them and need no change.

Claude-Session: https://claude.ai/code/session_016mBLURvJoMuUEr9cB2RpUN
This commit is contained in:
Niklas Ye
2026-10-10 13:29:08 +02:00
parent c67dc80a8f
commit f1754c583e
5 changed files with 29 additions and 2 deletions
+6 -1
View File
@@ -69,7 +69,11 @@ const incidentSelectFrom = `
i.acknowledged_by, i.acknowledged_at, ack.username,
i.acknowledged_by_service_account_id, acksa.name,
i.assigned_to, asg.username, i.snoozed_until,
i.resolved_at, i.resolution_source, i.archived_at
i.resolved_at, i.resolution_source, i.archived_at,
-- How many notes, so a list can flag the incidents that carry extra
-- information without fetching each timeline.
(SELECT count(*) FROM incident_events e WHERE e.incident_id = i.id AND e.type = 'note'),
(SELECT count(*) FROM incident_events e WHERE e.incident_id = i.id AND e.type = 'resolution_note')
FROM incidents i
JOIN teams t ON t.id = i.team_id
LEFT JOIN users ack ON ack.id = i.acknowledged_by
@@ -90,6 +94,7 @@ func scanIncident(s scanner) (models.Incident, error) {
&i.AcknowledgedByServiceAccountID, &i.AcknowledgedByServiceAccountName,
&i.AssignedToID, &i.AssignedToUser, &snoozedUntil,
&resolvedAt, &i.ResolutionSource, &archivedAt,
&i.NoteCount, &i.ResolutionNoteCount,
); err != nil {
return i, err
}