diff options
author | Christopher Baines <mail@cbaines.net> | 2019-12-02 13:30:36 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-12-12 20:07:22 +0000 |
commit | 8e5f8e4170dcb011d94d64316431ae44cb46769f (patch) | |
tree | a875bd307dc55dfd0bef3bf320bc14ec6b28729a /guix-data-service/model | |
parent | 2d87bd6340011cd403c2960acd691478292908da (diff) | |
download | data-service-8e5f8e4170dcb011d94d64316431ae44cb46769f.tar data-service-8e5f8e4170dcb011d94d64316431ae44cb46769f.tar.gz |
Add a new page for the narinfos associated with an output
Diffstat (limited to 'guix-data-service/model')
-rw-r--r-- | guix-data-service/model/nar.scm | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/guix-data-service/model/nar.scm b/guix-data-service/model/nar.scm index d511658..92c4d11 100644 --- a/guix-data-service/model/nar.scm +++ b/guix-data-service/model/nar.scm @@ -10,6 +10,7 @@ #:use-module (guix scripts substitute) #:use-module (guix-data-service model utils) #:export (select-outputs-for-successful-builds-without-known-nar-entries + select-nars-for-output select-signing-key record-narinfo-details-and-return-ids)) @@ -247,6 +248,55 @@ LIMIT 1500")) (map car (exec-query conn query (list (number->string build-server-id))))) +(define (select-nars-for-output conn output-file-name) + (define query + " +SELECT hash_algorithm, hash, size, + ( + SELECT JSON_AGG( + json_build_object('url', url, 'compression', compression, 'size', file_size) + ) + FROM nar_urls + WHERE nar_id = nars.id + ) AS urls, + ( + SELECT JSON_AGG( + json_build_object( + 'version', version, + 'host_name', host_name, + 'data_hash', data_hash, + 'data_hash_algorithm', data_hash_algorithm, + 'data', data_json, + 'sig_val', sig_val_json, + 'narinfo_signature_public_key', ( + SELECT sexp_json + FROM narinfo_signature_public_keys + WHERE narinfo_signature_public_keys.id = narinfo_signature_public_key_id + ), + 'body', narinfo_body, + 'signature_line', narinfo_signature_line + ) + ) + FROM narinfo_signature_data + INNER JOIN narinfo_signatures + ON narinfo_signature_data.id = narinfo_signatures.narinfo_signature_data_id + WHERE narinfo_signatures.nar_id = nars.id + ) +FROM nars +WHERE store_path = $1") + + (map + (match-lambda + ((hash-algorithm hash size urls-json signatures-json) + (list hash-algorithm + hash + (string->number size) + (vector->list + (json-string->scm urls-json)) + (vector->list + (json-string->scm signatures-json))))) + (exec-query conn query (list output-file-name)))) + (define (select-signing-key conn id) (define query " |