Add a blocking builds page
This commit is contained in:
parent
1fb291be40
commit
989916b740
3 changed files with 291 additions and 1 deletions
|
|
@ -17,17 +17,23 @@
|
|||
|
||||
(define-module (guix-data-service model blocked-builds)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-71)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (squee)
|
||||
#:use-module (json)
|
||||
#:use-module (guix-data-service database)
|
||||
#:use-module (guix-data-service utils)
|
||||
#:use-module (guix-data-service model utils)
|
||||
#:use-module (guix-data-service model system)
|
||||
#:use-module (guix-data-service model guix-revision)
|
||||
#:use-module (guix-data-service model build)
|
||||
#:export (handle-populating-blocked-builds-for-scheduled-builds
|
||||
handle-populating-blocked-builds-for-build-failures
|
||||
handle-removing-blocking-build-entries-for-successful-builds
|
||||
|
||||
backfill-blocked-builds))
|
||||
backfill-blocked-builds
|
||||
|
||||
select-blocking-builds))
|
||||
|
||||
(define (select-blocked-derivation-output-details-set-ids-for-blocking-build
|
||||
conn
|
||||
|
|
@ -301,3 +307,110 @@ FROM latest_build_status
|
|||
(simple-format #t "processed chunk...\n"))))
|
||||
1000
|
||||
build-ids)))
|
||||
|
||||
(define* (select-blocking-builds conn revision-commit
|
||||
#:key build-server-ids
|
||||
system target
|
||||
limit)
|
||||
(define query
|
||||
(string-append
|
||||
"
|
||||
WITH RECURSIVE all_derivations AS (
|
||||
(
|
||||
SELECT derivation_id
|
||||
FROM package_derivations
|
||||
INNER JOIN guix_revision_package_derivations
|
||||
ON package_derivations.id
|
||||
= guix_revision_package_derivations.package_derivation_id
|
||||
WHERE revision_id = $1"
|
||||
(if system
|
||||
(simple-format
|
||||
#f "
|
||||
AND system_id = ~A\n"
|
||||
(system->system-id conn system))
|
||||
"")
|
||||
(if target
|
||||
(simple-format
|
||||
#f "
|
||||
AND target = ~A\n"
|
||||
(quote-string target))
|
||||
"")
|
||||
"
|
||||
)
|
||||
UNION
|
||||
SELECT derivation_outputs.derivation_id
|
||||
FROM all_derivations
|
||||
INNER JOIN derivation_inputs
|
||||
ON all_derivations.derivation_id = derivation_inputs.derivation_id
|
||||
INNER JOIN derivation_outputs
|
||||
ON derivation_inputs.derivation_output_id = derivation_outputs.id
|
||||
), all_derivation_output_details_set_ids AS (
|
||||
SELECT derivations_by_output_details_set.*
|
||||
FROM derivations_by_output_details_set
|
||||
WHERE derivation_id IN (
|
||||
SELECT derivation_id FROM all_derivations
|
||||
)
|
||||
), blocked_build_counts AS (
|
||||
SELECT blocking_derivation_output_details_set_id, COUNT(*)
|
||||
FROM blocked_builds
|
||||
WHERE blocked_derivation_output_details_set_id IN
|
||||
(
|
||||
SELECT derivation_output_details_set_id
|
||||
FROM all_derivation_output_details_set_ids
|
||||
)
|
||||
GROUP BY 1
|
||||
)
|
||||
SELECT derivations.file_name,
|
||||
blocked_build_counts.count,
|
||||
(
|
||||
SELECT JSON_AGG(
|
||||
json_build_object(
|
||||
'build_server_id', builds.build_server_id,
|
||||
'build_server_build_id', builds.build_server_build_id,
|
||||
'status', latest_build_status.status,
|
||||
'timestamp', latest_build_status.timestamp,
|
||||
'build_for_equivalent_derivation',
|
||||
builds.derivation_file_name != derivations.file_name
|
||||
)
|
||||
ORDER BY latest_build_status.timestamp
|
||||
)
|
||||
FROM builds
|
||||
INNER JOIN latest_build_status
|
||||
ON builds.id = latest_build_status.build_id
|
||||
WHERE builds.derivation_output_details_set_id =
|
||||
blocked_build_counts.blocking_derivation_output_details_set_id"
|
||||
(if (and build-server-ids
|
||||
(not (null? build-server-ids)))
|
||||
(string-append
|
||||
"
|
||||
AND builds.build_server_id IN ("
|
||||
(string-join build-server-ids ", ")
|
||||
")")
|
||||
"")
|
||||
"
|
||||
) AS builds
|
||||
FROM blocked_build_counts
|
||||
INNER JOIN all_derivation_output_details_set_ids
|
||||
ON blocked_build_counts.blocking_derivation_output_details_set_id
|
||||
= all_derivation_output_details_set_ids.derivation_output_details_set_id
|
||||
INNER JOIN derivations
|
||||
ON all_derivation_output_details_set_ids.derivation_id
|
||||
= derivations.id
|
||||
ORDER BY 2 DESC"
|
||||
(if limit
|
||||
(string-append
|
||||
"
|
||||
LIMIT " (number->string limit))
|
||||
"")))
|
||||
|
||||
(map
|
||||
(match-lambda
|
||||
((derivation_file_name blocked_build_count builds)
|
||||
`((derivation_file_name . ,derivation_file_name)
|
||||
(blocked_build_count . ,blocked_build_count)
|
||||
(builds
|
||||
. ,(if (or (and (string? builds) (string-null? builds))
|
||||
(eq? #f builds))
|
||||
#()
|
||||
(json-string->scm builds))))))
|
||||
(exec-query conn query (list (commit->revision-id conn revision-commit)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue