[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/05: Add builds to the store item page
From: |
Christopher Baines |
Subject: |
05/05: Add builds to the store item page |
Date: |
Sat, 4 Jul 2020 04:32:06 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit e9d4e74e5606932f34e0f2ab30321ac8384c8edc
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sat Jul 4 09:31:12 2020 +0100
Add builds to the store item page
---
guix-data-service/model/build.scm | 30 ++++++++++++++++++++++++++++++
guix-data-service/web/controller.scm | 4 +++-
guix-data-service/web/view/html.scm | 18 +++++++++++++++++-
3 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/guix-data-service/model/build.scm
b/guix-data-service/model/build.scm
index 23e94bd..686e08d 100644
--- a/guix-data-service/model/build.scm
+++ b/guix-data-service/model/build.scm
@@ -24,6 +24,7 @@
#:export (select-build-stats
select-builds-with-context
select-builds-with-context-by-derivation-file-name
+ select-builds-with-context-by-derivation-output
select-build-by-build-server-and-build-server-build-id
select-build-by-build-server-and-derivation-file-name
select-required-builds-that-failed
@@ -228,6 +229,35 @@ ORDER BY latest_build_status.timestamp DESC")
(exec-query conn query (list derivation-file-name)))
+(define (select-builds-with-context-by-derivation-output conn output)
+ (define query
+ "
+SELECT build_servers.id,
+ build_servers.url,
+ builds.build_server_build_id,
+ builds.derivation_file_name,
+ latest_build_status.timestamp,
+ latest_build_status.status
+FROM builds
+INNER JOIN build_servers ON build_servers.id = builds.build_server_id
+INNER JOIN
+(
+ SELECT DISTINCT ON (build_id) *
+ FROM build_status
+ ORDER BY build_id, id DESC
+) AS latest_build_status
+ ON latest_build_status.build_id = builds.id
+INNER JOIN derivation_output_details_sets
+ ON builds.derivation_output_details_set_id =
+ derivation_output_details_sets.id
+INNER JOIN derivation_output_details
+ ON ARRAY[derivation_output_details.id] <@
+ derivation_output_details_sets.derivation_output_details_ids
+WHERE derivation_output_details.path = $1
+ORDER BY latest_build_status.timestamp DESC")
+
+ (exec-query-with-null-handling conn query (list output)))
+
(define (select-build-by-build-server-and-build-server-build-id
conn build-server-id build-server-build-id)
(define query
diff --git a/guix-data-service/web/controller.scm
b/guix-data-service/web/controller.scm
index d1cba66..ce5bb87 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -175,7 +175,9 @@
conn output-id))))
derivations)
(select-nars-for-output conn
- filename)))))))
+ filename)
+
(select-builds-with-context-by-derivation-output
+ conn filename)))))))
(define handle-static-assets
(if assets-dir-in-store?
diff --git a/guix-data-service/web/view/html.scm
b/guix-data-service/web/view/html.scm
index 9dcd7aa..2b1e4fb 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -439,7 +439,8 @@ time."
(define (view-store-item filename
derivations
derivations-using-store-item-list
- nars)
+ nars
+ builds)
(layout
#:body
`(,(header)
@@ -495,6 +496,21 @@ time."
(dd ,(assoc-ref signature "host_name"))))
signatures)))))))
nars)))
+ (div
+ (@ (class "row"))
+ (div
+ (@ (class "col-sm-12"))
+ (h2 "Builds")
+ ,@(map
+ (match-lambda
+ ((build-server-id build-server-url build-server-build-id
+ derivation-file-name
+ timestamp status)
+ `(a (@ (href ,(build-url build-server-id
+ build-server-build-id
+ derivation-file-name)))
+ ,(build-status-span status))))
+ builds)))
,@(map (lambda (derivation derivations-using-store-item)
`((div
(@ (class "row"))