aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-11-30 10:58:40 +0000
committerChristopher Baines <mail@cbaines.net>2019-11-30 10:58:40 +0000
commitb278065d2a0b201694e958cd65ad7a3553f4fd51 (patch)
tree61638ecce94c4ec5e1a2c1cf74c22ca1bff314b2
parent0aa78e9ef53e1d700b743ca396f1fe1cd597ff23 (diff)
downloaddata-service-b278065d2a0b201694e958cd65ad7a3553f4fd51.tar
data-service-b278065d2a0b201694e958cd65ad7a3553f4fd51.tar.gz
Fix selecting pending builds
-rw-r--r--guix-data-service/builds.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/guix-data-service/builds.scm b/guix-data-service/builds.scm
index e8b9d68..7bebc9b 100644
--- a/guix-data-service/builds.scm
+++ b/guix-data-service/builds.scm
@@ -152,12 +152,17 @@ SELECT builds.id, derivations.file_name
FROM derivations
INNER JOIN builds
ON derivations.file_name = builds.derivation_file_name
-INNER JOIN build_status
- ON builds.id = build_status.build_id
+LEFT JOIN (
+ SELECT DISTINCT ON (build_id) *
+ FROM build_status
+ ORDER BY build_id, timestamp DESC
+) AS latest_build_status
+ON builds.id = latest_build_status.build_id
WHERE builds.build_server_id = $1 AND
- build_status.status IN (
+ latest_build_status.status IN (
'scheduled', 'started'
)
+ORDER BY latest_build_status.status DESC -- 'started' first
LIMIT 1000")
(map