diff options
author | Ludovic Courtès <ludovic.courtes@inria.fr> | 2018-03-29 15:30:57 +0200 |
---|---|---|
committer | Ludovic Courtès <ludovic.courtes@inria.fr> | 2018-03-29 15:30:57 +0200 |
commit | 8eefd24672d257e8bdfe7abe063da1d01d14d762 (patch) | |
tree | 1a47e14fa2dcdfc484cf166b454c9e243a27b8cc /src/cuirass/database.scm | |
parent | 8bdde878c752a1518a2c4de991f466bd6cebe70b (diff) | |
download | cuirass-8eefd24672d257e8bdfe7abe063da1d01d14d762.tar cuirass-8eefd24672d257e8bdfe7abe063da1d01d14d762.tar.gz |
database: 'db-get-builds' honors 'status+submission-time' ordering again.
Fixes a regression introduced in
1bab5c4e56eb1849edc2cf0b23d433aeb2cac421 whereby the
'status+submission-time' order would no longer be honored.
As a result, /api/queue would return the queue ordered by build IDs,
making it largely useless.
* src/cuirass/database.scm (db-get-builds): Remove 'order' and rename
'order-column-name' to 'order'. Add case for 'status+submission-time'.
* tests/database.scm ("database")["db-get-builds"]: Move below
"db-update-build-status!" test. Add case for the
'status+submission-time' order.
Diffstat (limited to 'src/cuirass/database.scm')
-rw-r--r-- | src/cuirass/database.scm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm index d0c169b..b445719 100644 --- a/src/cuirass/database.scm +++ b/src/cuirass/database.scm @@ -460,17 +460,17 @@ Assumes that if group id stays the same the group headers stay the same." (let ((x-repeated-row (list->vector other-cells))) (collect-outputs x-builds-id x-repeated-row '() rows))))) - (let* ((order (if (eq? (assqx-ref filters 'order) 'build-id) - "ASC" - "DESC")) - (order-column-name - (match (assqx-ref filters 'order) - (('order 'build-id) "Builds.id") - (('order 'decreasing-build-id) "Builds.id") - (('order 'finish-time) "Builds.stoptime") - (('order 'start-time) "Builds.starttime") - (('order 'submission-time) "Builds.timestamp") - (_ "Builds.id"))) + (let* ((order (match (assq 'order filters) + (('order 'build-id) "Builds.id ASC") + (('order 'decreasing-build-id) "Builds.id DESC") + (('order 'finish-time) "Builds.stoptime DESC") + (('order 'start-time) "Builds.starttime DESC") + (('order 'submission-time) "Builds.timestamp DESC") + (('order 'status+submission-time) + ;; With this order, builds in 'running' state (-1) appear + ;; before those in 'scheduled' state (-2). + "Builds.status DESC, Builds.timestamp DESC") + (_ "Builds.id DESC"))) (stmt-text (format #f "\ SELECT Builds.id, Outputs.name, Outputs.path, Builds.timestamp, Builds.starttime, Builds.stoptime, Builds.log, Builds.status, Builds.derivation,\ Derivations.job_name, Derivations.system, Derivations.nix_name,\ @@ -486,7 +486,7 @@ AND (:jobset IS NULL OR (:jobset = Specifications.branch)) \ AND (:job IS NULL OR (:job = Derivations.job_name)) \ AND (:system IS NULL OR (:system = Derivations.system)) \ AND (:status IS NULL OR (:status = 'done' AND Builds.status >= 0) OR (:status = 'pending' AND Builds.status < 0)) \ -ORDER BY ~a ~a, Builds.id ASC LIMIT :nr;" order-column-name order)) +ORDER BY ~a, Builds.id ASC LIMIT :nr;" order)) (stmt (sqlite-prepare db stmt-text #:cache? #t))) (sqlite-bind-arguments stmt #:id (assqx-ref filters 'id) #:project (assqx-ref filters 'project) |