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: Sat, 18 Nov 2023 13:12:02 -0500 (EST)

branch: master
commit 9fdfd27c4faefbf28fb5c148d08defe97769b733
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Nov 18 18:03:38 2023 +0100

    database: Use ‘exec-query/bind’ some more.
    
    * src/cuirass/database.scm (db-get-builds-min, db-get-builds-max):
    Rewrite using ‘exec-query/bind’ instead of ‘exec-query/bind-params’.
---
 src/cuirass/database.scm | 50 +++++++++++++++++++++---------------------------
 1 file changed, 22 insertions(+), 28 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index c77ccc6..2b40afb 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -1989,41 +1989,35 @@ AND (Builds.system = :system OR :system IS NULL);")
   "Return the min build (stoptime, rowid) pair for the given evaluation EVAL
 and STATUS."
   (with-db-connection db
-    (let ((query "SELECT stoptime, id FROM Builds
-WHERE evaluation = :eval AND
-((:status = 'pending' AND Builds.status < 0) OR
-(:status = 'succeeded' AND Builds.status = 0) OR
-(:status = 'failed' AND Builds.status > 0) OR
-:status IS NULL)
+    (match (expect-one-row
+            (exec-query/bind db "SELECT stoptime, id FROM Builds
+WHERE evaluation = " eval " AND
+((" status " = 'pending' AND Builds.status < 0) OR
+ (" status " = 'succeeded' AND Builds.status = 0) OR
+ (" status " = 'failed' AND Builds.status > 0) OR
+  " status "::text IS NULL)
 ORDER BY stoptime ASC, id ASC
-LIMIT 1")
-          (params `((#:eval . ,eval)
-                    (#:status . ,status))))
-      (match (expect-one-row
-              (exec-query/bind-params db query params))
-        ((stoptime id) (list (string->number stoptime)
-                             (string->number id)))
-        (else #f)))))
+LIMIT 1"))
+      ((stoptime id) (list (string->number stoptime)
+                           (string->number id)))
+      (else #f))))
 
 (define (db-get-builds-max eval status)
   "Return the max build (stoptime, rowid) pair for the given evaluation EVAL
 and STATUS."
   (with-db-connection db
-    (let ((query "SELECT stoptime, id FROM Builds
-WHERE evaluation = :eval AND
-((:status = 'pending' AND Builds.status < 0) OR
-(:status = 'succeeded' AND Builds.status = 0) OR
-(:status = 'failed' AND Builds.status > 0) OR
-:status IS NULL)
+    (match (expect-one-row
+            (exec-query/bind db "SELECT stoptime, id FROM Builds
+WHERE evaluation = " eval " AND
+((" status " = 'pending' AND Builds.status < 0) OR
+ (" status " = 'succeeded' AND Builds.status = 0) OR
+ (" status " = 'failed' AND Builds.status > 0) OR
+  " status "::text IS NULL)
 ORDER BY stoptime DESC, id DESC
-LIMIT 1")
-          (params `((#:eval . ,eval)
-                    (#:status . ,status))))
-      (match (expect-one-row
-              (exec-query/bind-params db query params))
-        ((stoptime id) (list (string->number stoptime)
-                             (string->number id)))
-        (else #f)))))
+LIMIT 1"))
+      ((stoptime id) (list (string->number stoptime)
+                           (string->number id)))
+      (else #f))))
 
 (define (db-get-evaluation-specification eval)
   "Return specification of evaluation with id EVAL."



reply via email to

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