aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-12-26 08:52:04 +0000
committerChristopher Baines <mail@cbaines.net>2019-12-26 08:52:04 +0000
commit4eb5a3417c13f74745ec7ca3d92a95096c176da1 (patch)
treec811e26efc99981e7e77db192e20879965b1a414
parent566f20a03da5e31eac60f6f92236b170808d52fd (diff)
downloaddata-service-4eb5a3417c13f74745ec7ca3d92a95096c176da1.tar
data-service-4eb5a3417c13f74745ec7ca3d92a95096c176da1.tar.gz
Group derivation input outputs together by derivation
Both in terms of the code fetching the data from the database, as well as the formatted and detail outputs. This corrects an error in the formatted output for derivations where inputs would be duplicated.
-rw-r--r--guix-data-service/model/derivation.scm16
-rw-r--r--guix-data-service/web/view/html.scm18
2 files changed, 26 insertions, 8 deletions
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm
index 5d900fc..49973be 100644
--- a/guix-data-service/model/derivation.scm
+++ b/guix-data-service/model/derivation.scm
@@ -605,8 +605,13 @@ VALUES ($1, $2)"
(define query
(string-append
"
-SELECT derivations.file_name, derivation_outputs.name,
- derivation_output_details.path
+SELECT derivations.file_name,
+ JSON_AGG(
+ json_build_object(
+ 'output_name', derivation_outputs.name,
+ 'store_filename', derivation_output_details.path
+ )
+ )
FROM derivation_inputs
INNER JOIN derivation_outputs
ON derivation_outputs.id = derivation_inputs.derivation_output_id
@@ -615,9 +620,14 @@ INNER JOIN derivation_output_details
INNER JOIN derivations
ON derivation_outputs.derivation_id = derivations.id
WHERE derivation_inputs.derivation_id = $1
+GROUP BY derivations.file_name
ORDER BY derivations.file_name"))
- (exec-query conn query (list (number->string id))))
+ (map (match-lambda
+ ((derivation-file-name outputs-json)
+ (list derivation-file-name
+ (json-string->scm outputs-json))))
+ (exec-query conn query (list (number->string id)))))
(define (select-derivation-sources-by-derivation-id conn id)
(define query
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index 51c021c..8375d0b 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -551,10 +551,10 @@
(th "File name")))
(tdata
,@(map (match-lambda
- ((file-name output-name path)
+ ((derivation-file-name outputs)
`(tr
- (td (a (@ (href ,file-name))
- ,(display-store-item-short path))))))
+ (td (a (@ (href ,derivation-file-name))
+ ,(display-store-item-short derivation-file-name))))))
derivation-inputs)))))
(div
(@ (class "col-md-4"))
@@ -697,14 +697,22 @@
(@ (class "col-md-10")
(style "font-family: monospace;"))
,@(map (match-lambda*
- (((file-name output-name path) count-down)
+ (((file-name outputs) count-down)
`(div
(@ (style "margin-left: 3em;"))
"(\""
(a (@ (href ,file-name))
,(display-store-item file-name))
"\",\""
- "[\"" ,output-name "\"]"
+ "[" ,(string-join
+ (map (lambda (output)
+ (string-append
+ "\""
+ (assoc-ref output "output_name")
+ "\""))
+ (vector->list outputs))
+ ",")
+ "]"
")"
,@(if (eq? count-down 0)
'()