|
|
@ -232,8 +232,8 @@ router.get("/api/badge/:id/uptime/:duration?", cache("5 minutes"), async (reques
|
|
|
|
let requestedDuration = request.params.duration !== undefined ? request.params.duration : "24h";
|
|
|
|
let requestedDuration = request.params.duration !== undefined ? request.params.duration : "24h";
|
|
|
|
const overrideValue = value && parseFloat(value);
|
|
|
|
const overrideValue = value && parseFloat(value);
|
|
|
|
|
|
|
|
|
|
|
|
if (requestedDuration === "24") {
|
|
|
|
if (/^[0-9]+$/.test(requestedDuration)) {
|
|
|
|
requestedDuration = "24h";
|
|
|
|
requestedDuration = `${requestedDuration}h`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let publicMonitor = await R.getRow(`
|
|
|
|
let publicMonitor = await R.getRow(`
|
|
|
@ -265,7 +265,7 @@ router.get("/api/badge/:id/uptime/:duration?", cache("5 minutes"), async (reques
|
|
|
|
// build a label string. If a custom label is given, override the default one (requestedDuration)
|
|
|
|
// build a label string. If a custom label is given, override the default one (requestedDuration)
|
|
|
|
badgeValues.label = filterAndJoin([
|
|
|
|
badgeValues.label = filterAndJoin([
|
|
|
|
labelPrefix,
|
|
|
|
labelPrefix,
|
|
|
|
label ?? `Uptime (${requestedDuration}${labelSuffix})`,
|
|
|
|
label ?? `Uptime (${requestedDuration.slice(0, -1)}${labelSuffix})`,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
badgeValues.message = filterAndJoin([ prefix, cleanUptime, suffix ]);
|
|
|
|
badgeValues.message = filterAndJoin([ prefix, cleanUptime, suffix ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -302,8 +302,8 @@ router.get("/api/badge/:id/ping/:duration?", cache("5 minutes"), async (request,
|
|
|
|
let requestedDuration = request.params.duration !== undefined ? request.params.duration : "24h";
|
|
|
|
let requestedDuration = request.params.duration !== undefined ? request.params.duration : "24h";
|
|
|
|
const overrideValue = value && parseFloat(value);
|
|
|
|
const overrideValue = value && parseFloat(value);
|
|
|
|
|
|
|
|
|
|
|
|
if (requestedDuration === "24") {
|
|
|
|
if (/^[0-9]+$/.test(requestedDuration)) {
|
|
|
|
requestedDuration = "24h";
|
|
|
|
requestedDuration = `${requestedDuration}h`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check if monitor is public
|
|
|
|
// Check if monitor is public
|
|
|
@ -325,7 +325,7 @@ router.get("/api/badge/:id/ping/:duration?", cache("5 minutes"), async (request,
|
|
|
|
// use a given, custom labelColor or use the default badge label color (defined by badge-maker)
|
|
|
|
// use a given, custom labelColor or use the default badge label color (defined by badge-maker)
|
|
|
|
badgeValues.labelColor = labelColor ?? "";
|
|
|
|
badgeValues.labelColor = labelColor ?? "";
|
|
|
|
// build a lable string. If a custom label is given, override the default one (requestedDuration)
|
|
|
|
// build a lable string. If a custom label is given, override the default one (requestedDuration)
|
|
|
|
badgeValues.label = filterAndJoin([ labelPrefix, label ?? `Avg. Ping (${requestedDuration}${labelSuffix})` ]);
|
|
|
|
badgeValues.label = filterAndJoin([ labelPrefix, label ?? `Avg. Ping (${requestedDuration.slice(0, -1)}${labelSuffix})` ]);
|
|
|
|
badgeValues.message = filterAndJoin([ prefix, avgPing, suffix ]);
|
|
|
|
badgeValues.message = filterAndJoin([ prefix, avgPing, suffix ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|