From 3541869f774b5a94fe7ae49da13a334c631c0929 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Thu, 18 May 2023 12:45:24 +0100 Subject: [PATCH] Fix issue with counting up jobs that didn't finish We saw an issue with a negative amount for a new customer that only showed in the repo-level breakout. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- main.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 6a145b8..c19691e 100644 --- a/main.go +++ b/main.go @@ -231,16 +231,18 @@ func main() { summary := repoSummary[owner+"/"+repo.GetName()] for _, job := range jobs.Jobs { - dur := job.GetCompletedAt().Time.Sub(job.GetStartedAt().Time) - if dur > longestBuild { - longestBuild = dur - } - if dur > summary.LongestBuild { - summary.LongestBuild = dur + if !job.GetCompletedAt().IsZero() { + dur := job.GetCompletedAt().Time.Sub(job.GetStartedAt().Time) + if dur > longestBuild { + longestBuild = dur + } + if dur > summary.LongestBuild { + summary.LongestBuild = dur + } + + summary.TotalTime += dur } - summary.TotalTime += dur - if _, ok := conclusion[job.GetConclusion()]; !ok { conclusion[job.GetConclusion()] = 0 }