From 7da4469f492ae22fa6aeba71a2f37433c16a7606 Mon Sep 17 00:00:00 2001 From: Evangelos Skopelitis Date: Wed, 13 Nov 2024 09:37:23 -0500 Subject: [PATCH] frontend: Job: Add sort function for job durations This change adds a sort function for job duration times. Previously, sorting by duration would show the list of jobs out of order, but this should no longer be the case. Fixes: #2564 Signed-off-by: Evangelos Skopelitis --- frontend/src/components/job/List.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/job/List.tsx b/frontend/src/components/job/List.tsx index 42bac5b3b34..51d3af2bd97 100644 --- a/frontend/src/components/job/List.tsx +++ b/frontend/src/components/job/List.tsx @@ -111,14 +111,13 @@ export function JobsListRenderer(props: JobsListRendererProps) { id: 'duration', label: t('translation|Duration'), getValue: job => { - const startTime = job.status?.startTime; - const completionTime = job.status?.completionTime; - if (!!startTime && !!completionTime) { - const duration = new Date(completionTime).getTime() - new Date(startTime).getTime(); + const duration = job.getDuration(); + if (duration > 0) { return formatDuration(duration, { format: 'mini' }); } return '-'; }, + sort: (job1, job2) => job1.getDuration() - job2.getDuration(), gridTemplate: 0.6, }, {