aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/datastore/sqlite.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator/datastore/sqlite.scm')
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm66
1 files changed, 42 insertions, 24 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 5bdbc6f..ff30c0b 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -2,6 +2,7 @@
#:use-module (oop goops)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
+ #:use-module (srfi srfi-43)
#:use-module (srfi srfi-71)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
@@ -3256,16 +3257,18 @@ WHERE agent_id = :agent_id"
(define-method (datastore-list-allocation-plan-builds
(datastore <sqlite-datastore>)
- agent-id
- limit)
- (call-with-worker-thread
- (slot-ref datastore 'worker-reader-thread-channel)
- (lambda (db)
- (let ((statement
- (sqlite-prepare
- db
- ;; This needs to guard against the plan being out of date
- "
+ .
+ rest)
+ (apply
+ (lambda* (agent-id #:key limit)
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-reader-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ (string-append
+ "
SELECT builds.uuid, derivations.name
FROM builds
INNER JOIN derivations
@@ -3275,24 +3278,39 @@ INNER JOIN build_allocation_plan
WHERE build_allocation_plan.agent_id = :agent_id
AND builds.processed = 0
AND builds.id NOT IN (SELECT build_id FROM allocated_builds)
-ORDER BY build_allocation_plan.ordering ASC
+ORDER BY build_allocation_plan.ordering ASC"
+ (if limit
+ "
LIMIT :limit"
- #:cache? #t)))
+ ""))
+ #:cache? #t)))
- (sqlite-bind-arguments
- statement
- #:agent_id agent-id
- #:limit limit)
+ (apply sqlite-bind-arguments
+ statement
+ #:agent_id agent-id
+ (if limit
+ (list #:limit limit)
+ '()))
- (let ((builds (sqlite-map
- (match-lambda
- (#(uuid derivation_name)
- `((uuid . ,uuid)
- (derivation-name . ,derivation_name))))
- statement)))
- (sqlite-reset statement)
+ (let ((builds (sqlite-map
+ (match-lambda
+ (#(uuid derivation_name)
+ `((uuid . ,uuid)
+ (derivation-name . ,derivation_name)
+ (tags . ,(vector-map
+ (lambda (_ tag)
+ (match tag
+ ((key . value)
+ `((key . ,key)
+ (value . ,value)))))
+ (datastore-fetch-build-tags
+ datastore
+ uuid))))))
+ statement)))
+ (sqlite-reset statement)
- builds)))))
+ builds)))))
+ rest))
(define-method (datastore-list-agent-builds
(datastore <sqlite-datastore>)