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.
This commit is contained in:
1 parent
162b081858
commit
35ee4d3bcb
1 file changed
+17
-20
@@ -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 (
|
||||
<StatusBoxes shouldRender={shouldRender}>
|
||||
<StatBox
|
||||
heading="checks since"
|
||||
subHeading={
|
||||
<>
|
||||
{uptimeDuration}
|
||||
{streakTime}
|
||||
<Typography component="span">{t("ago")}</Typography>
|
||||
</>
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user