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.
This commit is contained in:
Christopher Baines 2019-11-30 10:55:16 +00:00
parent 0fa747e404
commit 0aa78e9ef5

View file

@ -35,14 +35,16 @@
build-status-strings build-status-strings
'("scheduled" "started"))) '("scheduled" "started")))
(let ((status-string (let* ((status-string
(assq-ref build-statuses (assq-ref build-statuses
(assoc-ref data "buildstatus"))) (assoc-ref data "buildstatus")))
(existing-status-entries (finished?
(map second (member status-string stop-statuses))
(select-build-statuses-by-build-id conn (existing-status-entries
build-id (map second
build-server-id))) (select-build-statuses-by-build-id conn
build-id
build-server-id)))
(timestamp (timestamp
(assoc-ref data "timestamp")) (assoc-ref data "timestamp"))
(starttime (starttime
@ -55,7 +57,12 @@
(filter (filter
list? list?
(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")) (list timestamp "scheduled"))
(when (and (< 0 starttime) (when (and (< 0 starttime)
(not (member "started" existing-status-entries))) (not (member "started" existing-status-entries)))