From e0179541879de0695fcfb2e7cd5232a5009c6842 Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Tue, 1 Mar 2022 16:04:27 +0100 Subject: [PATCH] Fix duration filter for running jobs --- repository/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repository/query.go b/repository/query.go index 92a58db..62d8041 100644 --- a/repository/query.go +++ b/repository/query.go @@ -124,7 +124,7 @@ func BuildWhereClause(filter *model.JobFilter, query sq.SelectBuilder) sq.Select } if filter.Duration != nil { now := time.Now().Unix() // There does not seam to be a portable way to get the current unix timestamp accross different DBs. - query = query.Where("(CASE job.job_state = 'running' THEN (? - job.start_time) ELSE job.duration END) BETWEEN ? AND ?", now, filter.Duration.From, filter.Duration.To) + query = query.Where("(CASE WHEN job.job_state = 'running' THEN (? - job.start_time) ELSE job.duration END) BETWEEN ? AND ?", now, filter.Duration.From, filter.Duration.To) } if filter.State != nil { states := make([]string, len(filter.State))