From fc1c54a1410544b5e483318c3ff7980c7a8e8e62 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Thu, 21 Nov 2024 14:39:03 +0100 Subject: [PATCH] fix: use left join to keep unmatched stats query result rows --- internal/repository/stats.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/repository/stats.go b/internal/repository/stats.go index ba7a8aa..f5677ad 100644 --- a/internal/repository/stats.go +++ b/internal/repository/stats.go @@ -86,7 +86,7 @@ func (r *JobRepository) buildStatsQuery( fmt.Sprintf(`CAST(ROUND(SUM((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) * job.num_hwthreads) / 3600) as %s) as totalCoreHours`, time.Now().Unix(), castType), fmt.Sprintf(`CAST(SUM(job.num_acc) as %s) as totalAccs`, castType), fmt.Sprintf(`CAST(ROUND(SUM((CASE WHEN job.job_state = "running" THEN %d - job.start_time ELSE job.duration END) * job.num_acc) / 3600) as %s) as totalAccHours`, time.Now().Unix(), castType), - ).From("job").Join("user ON user.username = job.user").GroupBy(col) + ).From("job").LeftJoin("user ON user.username = job.user").GroupBy(col) } else { // Scan columns: totalJobs, name, totalWalltime, totalNodes, totalNodeHours, totalCores, totalCoreHours, totalAccs, totalAccHours query = sq.Select("COUNT(job.id)", @@ -226,6 +226,8 @@ func (r *JobRepository) JobsStatsGrouped( TotalAccHours: totalAccHours, }) } else { + log.Debugf(">>>> STATS ID %s", id.String) + log.Debugf(">>>> STATS TOTALNODES %d", totalNodes) stats = append(stats, &model.JobsStatistics{ ID: id.String,