Skip to content
Snippets Groups Projects
Unverified Commit 158966dc authored by Mathieu Othacehe's avatar Mathieu Othacehe
Browse files

Fix /api/latestbuilds ordering.

Evaluations are added sequentially to database but builds are not always
registered nor performed in order. This means that a build corresponding to an
older evaluation can be returned first if it was completed last. Order by
descending evaluation id to prevent it.

* src/cuirass/database.scm (db-get-builds): Add "evaluation" order.
* src/cuirass/http.scm (url-handler): Order latestbuilds by descending
evaluation number.
parent e9e09439
No related branches found
No related tags found
No related merge requests found
......@@ -926,6 +926,7 @@ FILTERS is an assoc list whose possible keys are 'derivation | 'id | 'jobset |
(lambda (inner)
(match (assq 'order filters)
(('order . 'build-id) "Builds.id ASC")
(('order . 'evaluation) "Builds.evaluation DESC")
(('order . 'finish-time) "stoptime DESC")
(('order . 'finish-time+build-id)
(if inner
......
......@@ -490,12 +490,16 @@ Hydra format."
((> limit 1000)
(respond-json-with-error 500 "Maximum limit exceeded"))
(else
;; Limit results to builds that are "done".
;; Limit results to builds that are "done". Order the builds by
;; descending evaluation numbers. This ensures that the builds that
;; were last registered are first returned even if they take more
;; time to complete. Ordering by timestamp wouldn't work as
;; evaluations are not always performed sequentially.
(respond-json
(object->json-string
(handle-builds-request `((status . done)
,@params
(order . finish-time)))))))))
(order . evaluation)))))))))
(('GET "api" "queue")
(let* ((params (request-parameters request))
;; 'nr parameter is mandatory to limit query size.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment