Compute duration for running jobs on the fly

This commit is contained in:
Jan Eitzinger 2024-12-19 06:24:08 +01:00
parent f2d1a85afb
commit fd94d85edf
Signed by: moebiusband
GPG Key ID: 2574BA29B90D6DD5

View File

@ -80,6 +80,10 @@ func scanJob(row interface{ Scan(...interface{}) error }) (*schema.Job, error) {
job.RawFootprint = nil job.RawFootprint = nil
job.StartTime = time.Unix(job.StartTimeUnix, 0) 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 return job, nil
} }