guix-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Ludovic Courtès
Date: Tue, 5 Sep 2023 16:44:45 -0400 (EDT)

branch: master
commit 64d7ad1109ddf2c565dbe37f58a145b24e5b0fb5
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Sep 5 15:45:10 2023 +0200

    database: ‘db-get-evaluations-absolute-summary’ returns a full summary.
    
    * src/cuirass/database.scm (db-get-evaluations-absolute-summary): Extend
    SQL query and fill out all the <evaluation-summary> fields.
    * tests/database.scm ("db-get-evaluation-absolute-summary"): Check ‘status’.
    ("db-get-evaluations-absolute-summary"): Expect three results.
---
 src/cuirass/database.scm | 24 +++++++++++++++---------
 tests/database.scm       |  7 ++++---
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 6e2bf68..4590864 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -1872,16 +1872,23 @@ ORDER BY Evaluations.id ASC;"))
   (with-db-worker-thread db
     (let loop ((rows
                 (exec-query/bind db  "SELECT
+Evaluations.id, Evaluations.status,
+Evaluations.timestamp, Evaluations.checkouttime, Evaluations.evaltime,
 SUM(CASE WHEN Jobs.status > -100 THEN 1 ELSE 0 END) as total,
 SUM(CASE WHEN Jobs.status = 0 THEN 1 ELSE 0 END) AS succeeded,
 SUM(CASE WHEN Jobs.status > 0 THEN 1 ELSE 0 END) AS failed,
-SUM(CASE WHEN Jobs.status < 0 THEN 1 ELSE 0 END) AS scheduled,
-Jobs.evaluation FROM Jobs WHERE Jobs.evaluation = ANY(" eval-ids ")
-GROUP BY Jobs.evaluation;"))
+SUM(CASE WHEN Jobs.status < 0 THEN 1 ELSE 0 END) AS scheduled
+FROM Evaluations
+LEFT JOIN Jobs
+ON Jobs.evaluation = Evaluations.id
+WHERE Evaluations.id = ANY(" eval-ids ")
+GROUP BY Evaluations.id
+ORDER BY Evaluations.id ASC;"))
                (summary '()))
       (match rows
         (() (reverse summary))
-        (((total succeeded failed scheduled evaluation) . rest)
+        (((evaluation status timestamp checkouttime evaltime
+                      total succeeded failed scheduled) . rest)
          (loop rest
                (cons (evaluation-summary
                       (id (number evaluation))
@@ -1889,11 +1896,10 @@ GROUP BY Jobs.evaluation;"))
                       (succeeded (number succeeded))
                       (failed (number failed))
                       (scheduled (number scheduled))
-                      ;; FIXME: Info missing; use a different record type?
-                      (status *unspecified*)
-                      (start-time *unspecified*)
-                      (checkout-time *unspecified*)
-                      (completion-time *unspecified*))
+                      (status (number status))
+                      (start-time (number timestamp))
+                      (checkout-time (number checkouttime))
+                      (completion-time (number evaltime)))
                      summary)))))))
 
 (define (db-get-builds-query-min filters)
diff --git a/tests/database.scm b/tests/database.scm
index 035957f..a7e5354 100644
--- a/tests/database.scm
+++ b/tests/database.scm
@@ -417,17 +417,18 @@ timestamp, checkouttime, evaltime) VALUES ('guix', 0, 0, 
0, 0);")
              summaries))))
 
   (test-equal "db-get-evaluation-absolute-summary"
-    '(0 1 0)
+    (list 0 1 0 (evaluation-status succeeded))
     (with-fibers
       (let ((summary
              (db-get-evaluation-absolute-summary
               (db-get-latest-evaluation "guix"))))
         (list (evaluation-summary-succeeded summary)
               (evaluation-summary-failed summary)
-              (evaluation-summary-scheduled summary)))))
+              (evaluation-summary-scheduled summary)
+              (evaluation-summary-status summary)))))
 
   (test-equal "db-get-evaluations-absolute-summary"
-    '((0 1 0) (0 1 0))
+    '((0 1 0) (0 0 0) (0 1 0))
     (with-fibers
       (let* ((evaluations
               (db-get-evaluations-build-summary "guix" 3 #f #f))



reply via email to

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