diff options
author | Christopher Baines <mail@cbaines.net> | 2019-12-26 08:52:04 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-12-26 08:52:04 +0000 |
commit | 4eb5a3417c13f74745ec7ca3d92a95096c176da1 (patch) | |
tree | c811e26efc99981e7e77db192e20879965b1a414 /guix-data-service/model | |
parent | 566f20a03da5e31eac60f6f92236b170808d52fd (diff) | |
download | data-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.
Diffstat (limited to 'guix-data-service/model')
-rw-r--r-- | guix-data-service/model/derivation.scm | 16 |
1 files changed, 13 insertions, 3 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 |