guix-commits
[Top][All Lists]
Advanced

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

branch master updated: Fix /api/latestbuilds ordering.


From: Mathieu Othacehe
Subject: branch master updated: Fix /api/latestbuilds ordering.
Date: Sun, 31 Jan 2021 15:12:29 -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 158966d  Fix /api/latestbuilds ordering.
158966d is described below

commit 158966dca03351bd9cc1dbf1ad0ca744acba505f
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Sun Jan 31 21:09:17 2021 +0100

    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.
---
 src/cuirass/database.scm | 1 +
 src/cuirass/http.scm     | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index d2439e4..74e73bc 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -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
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index a37c63a..fab9888 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -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.



reply via email to

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