From d0d38abc61a45738b06c188e5f0079b44c881911 Mon Sep 17 00:00:00 2001 From: Arnei Date: Tue, 28 Jan 2025 10:34:07 +0100 Subject: [PATCH] Fix rendering of mean times Fixes #923. The "mean run time" and the "mean queue time" in the services table could show as timestamps instead of durations. This patch should fix that. --- src/components/systems/partials/MeanQueueTimeCell.tsx | 6 ++---- src/components/systems/partials/MeanRunTimeCell.tsx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/systems/partials/MeanQueueTimeCell.tsx b/src/components/systems/partials/MeanQueueTimeCell.tsx index 3eca7c3036..e39dd7ec37 100644 --- a/src/components/systems/partials/MeanQueueTimeCell.tsx +++ b/src/components/systems/partials/MeanQueueTimeCell.tsx @@ -1,7 +1,6 @@ import React from "react"; -import { useTranslation } from "react-i18next"; -import { renderValidDate } from "../../../utils/dateUtils"; import { Service } from "../../../slices/serviceSlice"; +import moment from "moment"; /** * This component renders the mean queue time cells of systems in the table view @@ -11,11 +10,10 @@ const MeanQueueTimeCell = ({ }: { row: Service }) => { - const { t } = useTranslation(); return ( - {t("dateFormats.time.medium", { time: renderValidDate(row.meanQueueTime.toString()) })} + { moment.utc(moment.duration(row.meanQueueTime* 1000).asMilliseconds()).format("HH:mm:ss") } ); }; diff --git a/src/components/systems/partials/MeanRunTimeCell.tsx b/src/components/systems/partials/MeanRunTimeCell.tsx index 229f4bf75d..c7707e8a41 100644 --- a/src/components/systems/partials/MeanRunTimeCell.tsx +++ b/src/components/systems/partials/MeanRunTimeCell.tsx @@ -1,7 +1,6 @@ import React from "react"; -import { useTranslation } from "react-i18next"; -import { renderValidDate } from "../../../utils/dateUtils"; import { Service } from "../../../slices/serviceSlice"; +import moment from "moment"; /** * This component renders the mean run time cells of systems in the table view @@ -11,11 +10,10 @@ const MeanRunTimeCell = ({ }: { row: Service }) => { - const { t } = useTranslation(); return ( - {t("dateFormats.time.medium", { time: renderValidDate(row.meanRunTime.toString()) })} + { moment.utc(moment.duration(row.meanRunTime * 1000).asMilliseconds()).format("HH:mm:ss") } ); };