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: Wed, 22 Nov 2023 05:12:26 -0500 (EST)

branch: master
commit 8cb3db46f12ae8aed9158ae42dae1cb05c058d2d
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Nov 21 23:27:53 2023 +0100

    database: Use ‘exec-query/bind’ yet some more.
    
    * src/cuirass/database.scm (db-get-evaluations-build-summary): Use
    ‘exec-query/bind’ instead of ‘exec-query/bind-params’.
---
 src/cuirass/database.scm | 49 ++++++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index ff2af72..d3dc478 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -1741,40 +1741,35 @@ ORDER BY id DESC LIMIT :limit;")
 
 (define (db-get-evaluations-build-summary spec limit border-low border-high)
   (with-db-connection db
-    (let ((query "
+    (let loop ((rows (exec-query/bind db "
 SELECT E.id, E.status,
 SUM(CASE WHEN B.status = 0 THEN 1 ELSE 0 END) as succeeded,
 SUM(CASE WHEN B.status > 0 THEN 1 ELSE 0 END) as failed,
 SUM(CASE WHEN B.status < 0 THEN 1 ELSE 0 END) as scheduled FROM
 (SELECT id, status FROM Evaluations
-WHERE specification=:spec
-AND (id > :borderlow OR :borderlow IS NULL)
-AND (id < :borderhigh OR :borderhigh IS NULL)
-ORDER BY CASE WHEN :borderlow IS NULL THEN id ELSE -id END DESC
-LIMIT :limit) E
+ WHERE specification = " spec "
+AND (id > " border-low " OR " border-low "::text IS NULL)
+AND (id < " border-high " OR " border-high "::text IS NULL)
+ORDER BY CASE WHEN " border-low "::text IS NULL THEN id ELSE -id END DESC
+LIMIT " limit ") E
 LEFT JOIN Builds as B
-ON B.evaluation=E.id
+ON B.evaluation = E.id
 GROUP BY E.id, E.status
-ORDER BY E.id DESC;")
-          (params `((#:spec . ,spec)
-                    (#:limit . ,limit)
-                    (#:borderlow . ,border-low)
-                    (#:borderhigh . ,border-high))))
-      (let loop ((rows (exec-query/bind-params db query params))
-                 (summaries '()))
-        (match rows
-          (()
-           (reverse summaries))
-          (((id status succeeded failed scheduled) . rest)
-           (loop rest
-                 (cons (build-summary
-                        (evaluation-id (string->number id))
-                        (status (string->number status))
-                        (checkouts (db-get-checkouts id))
-                        (succeeded (or (string->number succeeded) 0))
-                        (failed (or (string->number failed) 0))
-                        (scheduled (or (string->number scheduled) 0)))
-                       summaries))))))))
+ORDER BY E.id DESC;"))
+               (summaries '()))
+      (match rows
+        (()
+         (reverse summaries))
+        (((id status succeeded failed scheduled) . rest)
+         (loop rest
+               (cons (build-summary
+                      (evaluation-id (string->number id))
+                      (status (string->number status))
+                      (checkouts (db-get-checkouts id))
+                      (succeeded (or (string->number succeeded) 0))
+                      (failed (or (string->number failed) 0))
+                      (scheduled (or (string->number scheduled) 0)))
+                     summaries)))))))
 
 (define (db-get-previous-eval eval-id)
   "Return the successful evaluation preceeding EVAL-ID, for the same



reply via email to

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