guix-commits
[Top][All Lists]
Advanced

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

branch master updated: database: Fix search pagination.


From: Mathieu Othacehe
Subject: branch master updated: database: Fix search pagination.
Date: Sun, 17 Jan 2021 13:48:31 -0500

This is an automated email from the git hooks/post-receive script.

mothacehe pushed a commit to branch master
in repository guix-cuirass.

The following commit(s) were added to refs/heads/master by this push:
     new dea5707  database: Fix search pagination.
dea5707 is described below

commit dea570775064573881dbec0c849fd50ff907c31a
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Sun Jan 17 19:47:54 2021 +0100

    database: Fix search pagination.
    
    * src/cuirass/database.scm (db-get-builds-by-search): Fix pagination.
---
 src/cuirass/database.scm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 6f76100..0cc90e6 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -843,7 +843,9 @@ WHERE build = " build-id))
 FILTERS is an assoc list whose possible keys are the symbols query,
 border-low-id, border-high-id, and nr."
   (with-db-worker-thread db
-    (let* ((query (format #f "SELECT Builds.id, Builds.timestamp,
+    (let* ((query (format #f "
+SELECT * FROM
+(SELECT Builds.id, Builds.timestamp,
 Builds.starttime,Builds.stoptime, Builds.log, Builds.status,
 Builds.job_name, Builds.system, Builds.nix_name, Specifications.name
 FROM Builds
@@ -856,10 +858,10 @@ AND ((Builds.system = :system) OR :system IS NULL)
 AND ((:borderlowid < Builds.id) OR :borderlowid IS NULL)
 AND ((:borderhighid > Builds.id) OR :borderhighid IS NULL)
 ORDER BY
-CASE WHEN :borderlowid IS NULL THEN Builds.id
-                               ELSE -Builds.id
-END DESC
-LIMIT :nr;"))
+(CASE WHEN :borderlowid IS NULL THEN Builds.id
+ELSE -Builds.id END) DESC
+LIMIT :nr) Builds
+ORDER BY Builds.id DESC;"))
            (builds
             (exec-query/bind-params
              db
@@ -873,7 +875,7 @@ LIMIT :nr;"))
       (let loop ((builds builds)
                  (result '()))
         (match builds
-          (() result)
+          (() (reverse result))
           (((id timestamp starttime stoptime log status job-name
                 system nix-name specification)
             . rest)



reply via email to

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