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: Mon, 29 Jan 2018 12:07:17 -0500 (EST)

branch: master
commit fcd1bc13bce741a96a315ed0b0d06dc8e88519f9
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jan 29 11:59:45 2018 +0100

    http: /api/queue returns builds sorted by status.
    
    * src/cuirass/database.scm (db-get-builds)[format-order-clause]: Add
    'status+submission-time'.
    * src/cuirass/http.scm (url-handler) <"queue">: Use it.
---
 src/cuirass/database.scm |  4 ++++
 src/cuirass/http.scm     | 13 ++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 5ca3ad3..b3d0e74 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -361,6 +361,10 @@ FILTERS is an assoc list which possible keys are 'project 
| 'jobset | 'job |
                 "ORDER BY Builds.start DESC")
                (('order 'submission-time)
                 "ORDER BY Builds.timestamp DESC")
+               (('order 'status+submission-time)
+                ;; With this order, builds in 'running' state (-1) appear
+                ;; before those in 'scheduled' state (-2).
+                "ORDER BY Builds.status DESC, Builds.timestamp DESC")
                (_ #f))
              filters)
         "ORDER BY Builds.id DESC"))               ;default order
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 6b67379..b8a2996 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -179,11 +179,14 @@
             ;; 'nr parameter is mandatory to limit query size.
             (valid-params? (assq-ref params 'nr)))
        (if valid-params?
-           (respond-json (object->json-string
-                          (handle-builds-request db
-                                                 `((status pending)
-                                                   ,@params
-                                                   (order submission-time)))))
+           (respond-json
+            (object->json-string
+             ;; Use the 'status+submission-time' order so that builds in
+             ;; 'running' state appear before builds in 'scheduled' state.
+             (handle-builds-request db
+                                    `((status pending)
+                                      ,@params
+                                      (order status+submission-time)))))
            (respond-json-with-error 500 "Parameter not defined!"))))
     ('method-not-allowed
      ;; 405 "Method Not Allowed"



reply via email to

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