dowwntime 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +10 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/cli.mjs
CHANGED
|
@@ -28386,7 +28386,7 @@ const run = async (options) => {
|
|
|
28386
28386
|
let status = "down";
|
|
28387
28387
|
const statusCode = Math.max(...filteredResults.map((r) => r?.statusCode ?? 0));
|
|
28388
28388
|
if (options.getStatus) status = options.getStatus(statusCode, path$4, durationMs);
|
|
28389
|
-
else status = statusCode >= 200 ? "up" : "down";
|
|
28389
|
+
else status = statusCode >= 200 && statusCode < 300 ? "up" : "down";
|
|
28390
28390
|
const measurement = {
|
|
28391
28391
|
status,
|
|
28392
28392
|
durationMs,
|
|
@@ -28407,20 +28407,20 @@ const run = async (options) => {
|
|
|
28407
28407
|
}
|
|
28408
28408
|
const reports = await Promise.all([...fetchConfigurations.keys()].map(async (path$4) => {
|
|
28409
28409
|
const history = await measurements.getHistory(path$4);
|
|
28410
|
-
const startOfPast60m = (0, import_dayjs_min.default)().subtract(60, "minute").startOf("minute").
|
|
28411
|
-
const startOfPast24h = (0, import_dayjs_min.default)().subtract(24, "hours").startOf("hour").
|
|
28412
|
-
const startOfPast7d = (0, import_dayjs_min.default)().subtract(7, "day").startOf("day").
|
|
28413
|
-
const startOfPast30d = (0, import_dayjs_min.default)().subtract(30, "day").startOf("day").
|
|
28414
|
-
const
|
|
28410
|
+
const startOfPast60m = (0, import_dayjs_min.default)().subtract(60, "minute").startOf("minute").valueOf();
|
|
28411
|
+
const startOfPast24h = (0, import_dayjs_min.default)().subtract(24, "hours").startOf("hour").valueOf();
|
|
28412
|
+
const startOfPast7d = (0, import_dayjs_min.default)().subtract(7, "day").startOf("day").valueOf();
|
|
28413
|
+
const startOfPast30d = (0, import_dayjs_min.default)().subtract(30, "day").startOf("day").valueOf();
|
|
28414
|
+
const getAverageDuration = (since) => {
|
|
28415
28415
|
const filtered = history.filter((item) => item.timestamp >= since);
|
|
28416
28416
|
if (filtered.length === 0) return null;
|
|
28417
28417
|
const total = filtered.reduce((acc, curr) => acc + curr.durationMs, 0);
|
|
28418
28418
|
return Math.round(total / filtered.length);
|
|
28419
28419
|
};
|
|
28420
|
-
const avgDuration60m =
|
|
28421
|
-
const avgDuration24h =
|
|
28422
|
-
const avgDuration7d =
|
|
28423
|
-
const avgDuration30d =
|
|
28420
|
+
const avgDuration60m = getAverageDuration(startOfPast60m);
|
|
28421
|
+
const avgDuration24h = getAverageDuration(startOfPast24h);
|
|
28422
|
+
const avgDuration7d = getAverageDuration(startOfPast7d);
|
|
28423
|
+
const avgDuration30d = getAverageDuration(startOfPast30d);
|
|
28424
28424
|
const getRelativeDowntime = (since) => {
|
|
28425
28425
|
const filtered = history.filter((item) => item.timestamp >= since);
|
|
28426
28426
|
if (filtered.length === 0) return null;
|