From 0aa78e9ef53e1d700b743ca396f1fe1cd597ff23 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 30 Nov 2019 10:55:16 +0000 Subject: Don't create misleading scheduled build status entries Cuirass provides a timestamp field in build responses, and sometimes this means when the build was scheduled, but when the build is finished, it's the stoptime. So only use the timestamp when the build hasn't finished. --- guix-data-service/builds.scm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/guix-data-service/builds.scm b/guix-data-service/builds.scm index 4ac42fb..e8b9d68 100644 --- a/guix-data-service/builds.scm +++ b/guix-data-service/builds.scm @@ -35,14 +35,16 @@ build-status-strings '("scheduled" "started"))) - (let ((status-string - (assq-ref build-statuses - (assoc-ref data "buildstatus"))) - (existing-status-entries - (map second - (select-build-statuses-by-build-id conn - build-id - build-server-id))) + (let* ((status-string + (assq-ref build-statuses + (assoc-ref data "buildstatus"))) + (finished? + (member status-string stop-statuses)) + (existing-status-entries + (map second + (select-build-statuses-by-build-id conn + build-id + build-server-id))) (timestamp (assoc-ref data "timestamp")) (starttime @@ -55,7 +57,12 @@ (filter list? (list - (unless (member "scheduled" existing-status-entries) + (when (and + ;; Cuirass returns the stoptime as the timestamp if the + ;; build has finished, so only use the timestamp if the + ;; build hasn't finished. + (not finished?) + (not (member "scheduled" existing-status-entries))) (list timestamp "scheduled")) (when (and (< 0 starttime) (not (member "started" existing-status-entries))) -- cgit v1.2.3