This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch fix-pipeline-duration in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 998a644c63a054357d7e60606593aa8cae4ae1b4 Author: mintsweet <[email protected]> AuthorDate: Fri Sep 20 22:08:18 2024 +1200 fix: the start and end times are reversed --- config-ui/src/routes/pipeline/components/duration.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config-ui/src/routes/pipeline/components/duration.tsx b/config-ui/src/routes/pipeline/components/duration.tsx index 3620fa4bd..136b70e5c 100644 --- a/config-ui/src/routes/pipeline/components/duration.tsx +++ b/config-ui/src/routes/pipeline/components/duration.tsx @@ -26,20 +26,20 @@ const duration = (minute: number) => { } if (minute < 60) { - return `${Math.ceil(minute / 60)}m`; + return `${minute}m`; } if (minute < 60 * 24) { const hours = Math.floor(minute / 60); const minutes = minute - hours * 60; - return `${hours}h${minutes}m`; + return `${hours}h${minutes !== 0 ? `${minutes}m` : ''}`; } const days = Math.floor(minute / (60 * 24)); const hours = Math.floor((minute - days * 60 * 24) / 60); const minutes = minute - days * 60 * 24 - hours * 60; - return `${days}d${hours}h${minutes}m`; + return `${days}d${hours !== 0 ? `${hours}h` : ''}${minutes !== 0 ? `${minutes}m` : ''}`; }; interface Props { @@ -58,12 +58,12 @@ export const PipelineDuration = ({ status, beganAt, finishedAt }: Props) => { status, ) ) { - return <span>{duration(dayjs(beganAt).diff(dayjs(), 'm'))}</span>; + return <span>{duration(dayjs().diff(dayjs(beganAt), 'm'))}</span>; } if (!finishedAt) { return <span>-</span>; } - return <span>{duration(dayjs(beganAt).diff(dayjs(finishedAt), 'm'))}</span>; + return <span>{duration(dayjs(finishedAt).diff(dayjs(beganAt), 'm'))}</span>; };
