diff options
author | Ludovic Courtès <ludo@gnu.org> | 2018-01-29 11:59:45 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2018-01-29 18:06:47 +0100 |
commit | fcd1bc13bce741a96a315ed0b0d06dc8e88519f9 (patch) | |
tree | 6c9307fbde42c655f474d6818416503f9dac23f3 /src | |
parent | 5e959dd8f2bd9119758ff0fd056965bf2c6a6b21 (diff) | |
download | cuirass-fcd1bc13bce741a96a315ed0b0d06dc8e88519f9.tar cuirass-fcd1bc13bce741a96a315ed0b0d06dc8e88519f9.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/cuirass/database.scm | 4 | ||||
-rw-r--r-- | 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" |