Skip to content

Commit 04d39fb

Browse files
♻️ Show degraded performance in README
1 parent ee91b1e commit 04d39fb

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

β€Žsrc/interfaces.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ export interface UpptimeConfig {
4141
liveStatusHtmlComment?: string;
4242
commitPrefixStatusUp?: string;
4343
commitPrefixStatusDown?: string;
44+
commitPrefixStatusDegraded?: string;
4445
i18n?: {
4546
up?: string;
4647
down?: string;
48+
degraded?: string;
4749
url?: string;
4850
status?: string;
4951
history?: string;
@@ -53,6 +55,7 @@ export interface UpptimeConfig {
5355
responseTimeGraphAlt?: string;
5456
liveStatus?: string;
5557
allSystemsOperational?: string;
58+
degradedPerformance?: string;
5659
completeOutage?: string;
5760
partialOutage?: string;
5861
} & Record<string, string>;

β€Žsrc/summary.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ export const generateSummary = async () => {
2929
// This object will track the summary data of all sites
3030
const pageStatuses: Array<SiteStatus> = [];
3131

32-
// We'll keep incrementing this if there are down sites
32+
// We'll keep incrementing this if there are down/degraded sites
3333
// This is used to show the overall status later
3434
let numberOfDown = 0;
35+
let numberOfDegraded = 0;
3536

3637
// Loop through each site and add compute the current status
3738
for await (const site of config.sites) {
@@ -64,11 +65,15 @@ export const generateSummary = async () => {
6465
.filter((item) => item && !isNaN(item))
6566
.reduce((p, c) => p + c, 0) / history.data.length;
6667

67-
// Current status is "up" or "down" based on the emoji prefix of the commit message
68-
const status = history.data[0].commit.message
68+
// Current status is "up", "down", or "degraded" based on the emoji prefix of the commit message
69+
const status: "up" | "down" | "degraded" = history.data[0].commit.message
6970
.split(" ")[0]
7071
.includes(config.commitPrefixStatusUp || "🟩")
7172
? "up"
73+
: history.data[0].commit.message
74+
.split(" ")[0]
75+
.includes(config.commitPrefixStatusDegraded || "🟨")
76+
? "degraded"
7277
: "down";
7378

7479
pageStatuses.push({
@@ -80,6 +85,7 @@ export const generateSummary = async () => {
8085
time: Math.floor(averageTime),
8186
});
8287
if (status === "down") numberOfDown++;
88+
if (status === "degraded") numberOfDegraded++;
8389
}
8490

8591
let website = `https://${config.owner}.github.io/${config.repo}`;
@@ -100,7 +106,11 @@ ${pageStatuses
100106
.map(
101107
(page) =>
102108
`| ${page.url.includes("$") ? page.name : `[${page.name}](${page.url})`} | ${
103-
page.status === "up" ? i18n.up || "🟩 Up" : i18n.down || "πŸŸ₯ Down"
109+
page.status === "up"
110+
? i18n.up || "🟩 Up"
111+
: page.status === "degraded"
112+
? i18n.degraded || "🟨 Degraded"
113+
: i18n.down || "πŸŸ₯ Down"
104114
} | [${page.slug}.yml](https://github.com/${owner}/${repo}/commits/master/history/${
105115
page.slug
106116
}.yml) | <img alt="${i18n.responseTimeGraphAlt || "Response time graph"}" src="./graphs/${
@@ -224,10 +234,12 @@ ${config.summaryEndHtmlComment || "<!--end: status pages-->"}${endText}`;
224234
if (line.includes("<!--live status-->")) {
225235
line = `${line.split("<!--live status-->")[0]}<!--live status--> **${
226236
numberOfDown === 0
227-
? i18n.allSystemsOperational || "🟩 All systems operational"
237+
? numberOfDegraded === 0
238+
? i18n.allSystemsOperational || "🟩 All systems operational"
239+
: i18n.degradedPerformance || "🟨 Degraded performance"
228240
: numberOfDown === config.sites.length
229241
? i18n.completeOutage || "πŸŸ₯ Complete outage"
230-
: i18n.partialOutage || "🟨 Partial outage"
242+
: i18n.partialOutage || "🟧 Partial outage"
231243
}**`;
232244
}
233245
return line;

0 commit comments

Comments
Β (0)