guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

11/11: Split the jobs metric in to succeede, queued and failed


From: Christopher Baines
Subject: 11/11: Split the jobs metric in to succeede, queued and failed
Date: Fri, 9 Oct 2020 15:21:21 -0400 (EDT)

cbaines pushed a commit to branch master
in repository data-service.

commit 4f3be14c1691e475210bda21671f337e5943178b
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Oct 9 20:19:28 2020 +0100

    Split the jobs metric in to succeede, queued and failed
    
    Rather than just completed or not.
---
 guix-data-service/jobs/load-new-guix-revision.scm | 21 ++++++++++++++++++---
 guix-data-service/web/controller.scm              |  4 ++--
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/guix-data-service/jobs/load-new-guix-revision.scm 
b/guix-data-service/jobs/load-new-guix-revision.scm
index 691cda1..c399763 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -1365,7 +1365,22 @@ RETURNING id;")
   (define query
     "
 SELECT COALESCE(git_repositories.label, git_repositories.url) AS 
repository_label,
-       succeeded_at IS NOT NULL AS completed,
+       CASE WHEN succeeded_at IS NOT NULL
+            THEN 'succeeded'
+            WHEN (
+                   SELECT COUNT(*)
+                   FROM load_new_guix_revision_job_events
+                   WHERE job_id = load_new_guix_revision_jobs.id
+                     AND event = 'retry'
+                 ) >= (
+                   SELECT COUNT(*)
+                   FROM load_new_guix_revision_job_events
+                   WHERE job_id = load_new_guix_revision_jobs.id
+                     AND event = 'failure'
+                 )
+            THEN 'queued'
+            ELSE 'failed'
+       END AS state,
        COUNT(*)
 FROM load_new_guix_revision_jobs
 INNER JOIN git_repositories
@@ -1374,9 +1389,9 @@ INNER JOIN git_repositories
 GROUP BY 1, 2")
 
   (map (match-lambda
-         ((label completed count)
+         ((label state count)
           (list label
-                (string=? "t" completed)
+                state
                 (string->number count))))
        (exec-query conn query)))
 
diff --git a/guix-data-service/web/controller.scm 
b/guix-data-service/web/controller.scm
index 4727771..6adc093 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -223,13 +223,13 @@
              pg-stat-user-indexes-metrics)
 
         (for-each (match-lambda
-                    ((repository-label completed count)
+                    ((repository-label state count)
                      (metric-set
                       load-new-guix-revision-job-count
                       count
                       #:label-values
                       `((repository_label . ,repository-label)
-                        (completed        . ,(if completed "yes" "no"))))))
+                        (state            . ,state)))))
                   load-new-guix-revision-job-metrics)
 
         (list (build-response



reply via email to

[Prev in Thread] Current Thread [Next in Thread]