aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/model/derivation.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-05-23 22:39:32 +0100
committerChristopher Baines <mail@cbaines.net>2022-05-23 22:39:32 +0100
commit6d403cbc8d9b191ede4dc0a4d3bc7c81d17871ee (patch)
tree023f3a12da7744d79e7a20f0c00cf138e4719b7a /guix-data-service/model/derivation.scm
parent40035bcf9a3bfb260b44c56cea914ec5c7e438b0 (diff)
downloaddata-service-6d403cbc8d9b191ede4dc0a4d3bc7c81d17871ee.tar
data-service-6d403cbc8d9b191ede4dc0a4d3bc7c81d17871ee.tar.gz
Allow filtering package derivations based on build server builds
This means you can query for derivations where builds exist or don't exist on a given build server. I think this will come in useful when submitting builds from a Guix Data Service instance.
Diffstat (limited to 'guix-data-service/model/derivation.scm')
-rw-r--r--guix-data-service/model/derivation.scm52
1 files changed, 52 insertions, 0 deletions
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm
index f09435e..a6a0944 100644
--- a/guix-data-service/model/derivation.scm
+++ b/guix-data-service/model/derivation.scm
@@ -191,6 +191,8 @@ ORDER BY systems.system DESC,
targets
minimum-builds
maximum-builds
+ build-from-build-servers
+ no-build-from-build-servers
limit-results
after-name
(include-builds? #t)
@@ -238,6 +240,30 @@ ORDER BY systems.system DESC,
) <= "
(number->string maximum-builds)))
'())
+ ,@(map
+ (lambda (build-server-id)
+ (string-append
+ "
+EXISTS(
+ SELECT 1
+ FROM builds
+ WHERE builds.derivation_output_details_set_id =
+ derivations_by_output_details_set.derivation_output_details_set_id
+ AND builds.build_server_id = " (number->string build-server-id) "
+)"))
+ (or build-from-build-servers '()))
+ ,@(map
+ (lambda (build-server-id)
+ (string-append
+ "
+NOT EXISTS(
+ SELECT 1
+ FROM builds
+ WHERE builds.derivation_output_details_set_id =
+ derivations_by_output_details_set.derivation_output_details_set_id
+ AND builds.build_server_id = " (number->string build-server-id) "
+)"))
+ (or no-build-from-build-servers '()))
,@(cond
((eq? build-status #f) '())
((eq? build-status 'failing)
@@ -382,6 +408,8 @@ ORDER BY derivations.file_name
targets
minimum-builds
maximum-builds
+ build-from-build-servers
+ no-build-from-build-servers
limit-results
after-name
(include-builds? #t)
@@ -429,6 +457,30 @@ ORDER BY derivations.file_name
) <= "
(number->string maximum-builds)))
'())
+ ,@(map
+ (lambda (build-server-id)
+ (string-append
+ "
+EXISTS(
+ SELECT 1
+ FROM builds
+ WHERE builds.derivation_output_details_set_id =
+ derivations_by_output_details_set.derivation_output_details_set_id
+ AND builds.build_server_id = " (number->string build-server-id) "
+)"))
+ (or build-from-build-servers '()))
+ ,@(map
+ (lambda (build-server-id)
+ (string-append
+ "
+NOT EXISTS(
+ SELECT 1
+ FROM builds
+ WHERE builds.derivation_output_details_set_id =
+ derivations_by_output_details_set.derivation_output_details_set_id
+ AND builds.build_server_id = " (number->string build-server-id) "
+)"))
+ (or no-build-from-build-servers '()))
,@(cond
((eq? build-status #f) '())
((eq? build-status 'failing)