Skip to content

Open-source status page, incident response and uptime monitoring

fix: add status labels for card value - duration (private locations) (#2487)

Maxbaf5f0404c27
diff --git a/packages/api/src/router/statusPage.utils.ts b/packages/api/src/router/statusPage.utils.ts
index f7d25d451..8f1613b5c 100644
--- a/packages/api/src/router/statusPage.utils.ts
+++ b/packages/api/src/router/statusPage.utils.ts
@@ -95,9 +95,9 @@ function formatNumber(num: number): string {
function isToday(date: Date): boolean {
const today = new Date();
return (
- date.getDate() === today.getDate() &&
- date.getMonth() === today.getMonth() &&
- date.getFullYear() === today.getFullYear()
+ date.getUTCDate() === today.getUTCDate() &&
+ date.getUTCMonth() === today.getUTCMonth() &&
+ date.getUTCFullYear() === today.getUTCFullYear()
);
}
@@ -543,14 +543,37 @@ export function setDataByType({
cardData = entries
.map((entry) => {
// Map each entry status to its corresponding events
- const eventMap = {
+ const eventByStatus: Record<string, Event[]> = {
error: incidents,
degraded: reports,
info: maintenances,
success: [], // Success is calculated differently
};
+ const events = eventByStatus[entry.status];
+
+ // When there are no events for this status but the data shows a
+ // non-zero count, calculate a proportional duration from the data
+ // so the card reflects actual probe-based status, not just events.
+ if (
+ events.length === 0 &&
+ (entry.status === "error" || entry.status === "degraded") &&
+ entry.count > 0
+ ) {
+ const totalMinutes = getAdjustedTotalMinutesInDay(
+ date,
+ maintenances,
+ );
+ const statusMinutes = Math.round(
+ (entry.count / total) * totalMinutes,
+ );
+ if (statusMinutes === 0) return null;
+ durationMap.set(entry.status, statusMinutes);
+ return {
+ status: entry.status,
+ value: formatDuration(statusMinutes),
+ };
+ }
- const events = eventMap[entry.status as keyof typeof eventMap];
return createDurationCardEntry(
entry.status,
events,