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.
This commit is contained in:
Christopher Baines 2019-12-26 08:52:04 +00:00
parent 566f20a03d
commit 4eb5a3417c
2 changed files with 26 additions and 8 deletions

View file

@ -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

View file

@ -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)
'()