From a7dd3fbc0b531ce73311d2fe937321672e79d333 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 24 Aug 2023 14:26:23 +0200 Subject: [PATCH] fix bug in stats AddJobCount --- internal/repository/stats.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/repository/stats.go b/internal/repository/stats.go index 8a74008..ee48ee1 100644 --- a/internal/repository/stats.go +++ b/internal/repository/stats.go @@ -321,7 +321,7 @@ func (r *JobRepository) AddJobCount( return nil, err } - counts := make(map[string]int) + var count int for rows.Next() { var cnt sql.NullInt64 @@ -329,20 +329,22 @@ func (r *JobRepository) AddJobCount( log.Warn("Error while scanning rows") return nil, err } + + count = int(cnt.Int64) } switch kind { case "running": for _, s := range stats { - s.RunningJobs = counts[s.ID] + s.RunningJobs = count } case "short": for _, s := range stats { - s.ShortJobs = counts[s.ID] + s.ShortJobs = count } } - log.Debugf("Timer JobJobCount %s", time.Since(start)) + log.Debugf("Timer AddJobCount %s", time.Since(start)) return stats, nil }