aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-07-07 18:23:53 +0100
committerChristopher Baines <mail@cbaines.net>2022-07-07 18:23:53 +0100
commit49ea0deba5d985812d52836f4aa193408be698c8 (patch)
treef28a566aa552bcadc991c336c197fe6f6229ea7d
parentcfd3f8d49aa16772b9b62cc24aff6c1e68b27f63 (diff)
downloadbuild-coordinator-49ea0deba5d985812d52836f4aa193408be698c8.tar
build-coordinator-49ea0deba5d985812d52836f4aa193408be698c8.tar.gz
Support listing builds by priority
-rw-r--r--guix-build-coordinator/client-communication.scm16
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm15
-rw-r--r--scripts/guix-build-coordinator.in14
3 files changed, 44 insertions, 1 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm
index 124caab..2453800 100644
--- a/guix-build-coordinator/client-communication.scm
+++ b/guix-build-coordinator/client-communication.scm
@@ -369,6 +369,14 @@
((_ . val)
(string=? val "true"))
(#f 'unset))
+ #:priority->
+ (or (and=> (assq-ref query-parameters 'priority_gt)
+ string->number)
+ 'unset)
+ #:priority-<
+ (or (and=> (assq-ref query-parameters 'priority_lt)
+ string->number)
+ 'unset)
#:after-id
(assq-ref query-parameters 'after_id)
#:limit
@@ -580,6 +588,8 @@
(not-systems '())
(processed 'unset)
(canceled 'unset)
+ (priority-> 'unset)
+ (priority-< 'unset)
(after-id #f)
(limit 1000))
(let ((query-parameters
@@ -621,6 +631,12 @@
'("canceled=true")
'("canceled=false"))
'())
+ ,@(if (number? priority->)
+ (list (simple-format #f "priority_gt=~A" priority->))
+ '())
+ ,@(if (number? priority-<)
+ (list (simple-format #f "priority_lt=~A" priority-<))
+ '())
,@(if after-id
(list (string-append "after_id=" after-id))
'())
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index a6c93f3..bf90fc5 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -1736,6 +1736,8 @@ WHERE uuid = :uuid"
(not-systems '())
(processed 'unset)
(canceled 'unset)
+ (priority-> 'unset)
+ (priority-< 'unset)
(after-id #f)
(limit 1000))
(call-with-worker-thread
@@ -1817,8 +1819,11 @@ SELECT id FROM tags WHERE key = :key"
(not (null? not-tag-expressions))
(not (null? systems))
(not (null? not-systems))
+ (not (eq? priority-> 'unset))
+ (not (eq? priority-< 'unset))
(not (eq? processed 'unset))
- (not (eq? canceled 'unset))))
+ (not (eq? canceled 'unset))
+ after-id))
(statement
(sqlite-prepare
db
@@ -1865,6 +1870,14 @@ LEFT JOIN (
#f "derivations.system_id != ~A"
(db-system->system-id db system)))
not-systems)
+ (if (number? priority->)
+ (list
+ (simple-format #f "priority > ~A" priority->))
+ '())
+ (if (number? priority-<)
+ (list
+ (simple-format #f "priority < ~A" priority-<))
+ '())
(cond
((eq? processed #t) '("processed = 1"))
((eq? processed #f) '("processed = 0"))
diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in
index c9e7ee9..937ee4b 100644
--- a/scripts/guix-build-coordinator.in
+++ b/scripts/guix-build-coordinator.in
@@ -188,6 +188,16 @@
(alist-cons 'canceled
(string=? arg "true")
result)))
+ (option '("priority-gt") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'priority->
+ (string->number arg)
+ result)))
+ (option '("priority-lt") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'priority-<
+ (string->number arg)
+ result)))
(option '("after-id") #t #f
(lambda (opt name arg result)
(alist-cons 'after-id
@@ -206,6 +216,8 @@
(not-systems . ())
(processed . 'unset)
(canceled . 'unset)
+ (priority-> . 'unset)
+ (priority-< . 'unset)
(limit . 1000)))
(define %build-cancel-options
@@ -479,6 +491,8 @@ canceled?: ~A
#:not-systems (assq-ref opts 'not-systems)
#:processed (assq-ref opts 'processed)
#:canceled (assq-ref opts 'canceled)
+ #:priority-> (assq-ref opts 'priority->)
+ #:priority-< (assq-ref opts 'priority-<)
#:after-id (or after-id (assq-ref opts 'after-id))
#:limit (assq-ref opts 'limit))))
(for-each