From fd94d85edf9606dba70cb2233fb19a51f78ff080 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 19 Dec 2024 06:24:08 +0100 Subject: [PATCH] Compute duration for running jobs on the fly --- internal/repository/job.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/repository/job.go b/internal/repository/job.go index 2c206b6..11f3b46 100644 --- a/internal/repository/job.go +++ b/internal/repository/job.go @@ -80,6 +80,10 @@ func scanJob(row interface{ Scan(...interface{}) error }) (*schema.Job, error) { job.RawFootprint = nil job.StartTime = time.Unix(job.StartTimeUnix, 0) + // Always ensure accurate duration for running jobs + if job.State == schema.JobStateRunning { + job.Duration = int32(time.Since(job.StartTime).Seconds()) + } return job, nil }