From 35ee4d3bcbf50525a63ccdded5a4babe42bdca41 Mon Sep 17 00:00:00 2001 From: gorkem-bwl Date: Fri, 16 Jan 2026 21:53:48 -0500 Subject: [PATCH] revert: Remove PageSpeed stats fix (already fixed on develop) The PageSpeed stats fix has been implemented differently on develop branch by Alex Holliday in commit 6447c315c. Reverting this change to avoid conflicts and keep the incidents fixes. --- .../Components/PageSpeedStatusBoxes/index.jsx | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/client/src/Pages/PageSpeed/Details/Components/PageSpeedStatusBoxes/index.jsx b/client/src/Pages/PageSpeed/Details/Components/PageSpeedStatusBoxes/index.jsx index 13d7edf8c..872b1e293 100644 --- a/client/src/Pages/PageSpeed/Details/Components/PageSpeedStatusBoxes/index.jsx +++ b/client/src/Pages/PageSpeed/Details/Components/PageSpeedStatusBoxes/index.jsx @@ -4,34 +4,31 @@ import { Typography } from "@mui/material"; import { getHumanReadableDuration } from "../../../../../Utils/timeUtils.js"; import { useTranslation } from "react-i18next"; -const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => { +const PageSpeedStatusBoxes = ({ shouldRender, monitorStats }) => { + const lastChecked = monitorStats?.lastCheckTimestamp + ? Date.now() - monitorStats.lastCheckTimestamp + : 0; + + // Determine time since last failure + const timeOfLastFailure = monitorStats?.timeOfLastFailure; + const timeSinceLastFailure = + timeOfLastFailure > 0 + ? Date.now() - timeOfLastFailure + : Date.now() - new Date(monitorStats?.createdAt); + + const streakTime = getHumanReadableDuration(timeSinceLastFailure); + + const time = getHumanReadableDuration(lastChecked); + const { t } = useTranslation(); - // Calculate time since first check (checks since) - const checks = monitor?.checks || []; - const oldestCheck = checks.length > 0 ? checks[checks.length - 1] : null; - const oldestCheckTime = oldestCheck?.createdAt - ? new Date(oldestCheck.createdAt).getTime() - : null; - const checksSinceDuration = oldestCheckTime ? Date.now() - oldestCheckTime : 0; - - // Calculate time since last check - const latestCheck = checks.length > 0 ? checks[0] : null; - const latestCheckTime = latestCheck?.createdAt - ? new Date(latestCheck.createdAt).getTime() - : null; - const lastCheckDuration = latestCheckTime ? Date.now() - latestCheckTime : 0; - - const uptimeDuration = getHumanReadableDuration(checksSinceDuration); - const time = getHumanReadableDuration(lastCheckDuration); - return ( - {uptimeDuration} + {streakTime} {t("ago")} }