Skip to content

Commit 378cad9

Browse files
balazstasiCopilotmrshu
authored
fix(badges): aggregate incident timeline status count (#27)
* fix: aggregate timeline status badges Show one badge per status in incident timeline cards and append the total count for repeated statuses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(badges): preserve timeline status phases Previously status badges were counted globally, which could hide repeated non-contiguous incident phases. This commit summarizes only consecutive runs and keeps malformed status sequences from breaking card rendering. - Make `summarizeStatuses` ignore non-array inputs - Collapse adjacent duplicate statuses while preserving timeline order - Keep repeated phase transitions visible in incident cards --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: mr.Shu <mr@shu.io>
1 parent 5e29cd6 commit 378cad9

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

site/app.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,22 @@ const formatTime = (date) =>
129129
const incidentStartDate = (incident) =>
130130
incident.downtime_start ? new Date(incident.downtime_start) : new Date(incident.published_at);
131131

132+
const summarizeStatuses = (statuses = []) => {
133+
if (!Array.isArray(statuses)) return [];
134+
135+
return statuses.filter(Boolean).reduce((summary, status) => {
136+
const previous = summary[summary.length - 1];
137+
138+
if (previous?.status === status) {
139+
previous.count += 1;
140+
} else {
141+
summary.push({ status, count: 1 });
142+
}
143+
144+
return summary;
145+
}, []).map(({ status, count }) => (count > 1 ? `${status} (${count})` : status));
146+
};
147+
132148
const parseJSONL = (text) =>
133149
text
134150
.split(/\r?\n/)
@@ -1265,7 +1281,7 @@ const renderIncidentCard = (incident, compact = false) => {
12651281

12661282
const timeline = document.createElement('div');
12671283
timeline.className = 'timeline';
1268-
(incident.status_sequence || []).forEach((status) => {
1284+
summarizeStatuses(incident.status_sequence).forEach((status) => {
12691285
const pill = document.createElement('span');
12701286
pill.textContent = status;
12711287
timeline.appendChild(pill);

0 commit comments

Comments
 (0)