aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-01-31 20:24:27 +0000
committerChristopher Baines <mail@cbaines.net>2022-01-31 20:24:27 +0000
commitf1418c4e88e9fc77e9a450fa1c01471e897774f3 (patch)
treed9fb2f5d82dfd649b5edbe15b1d1bf9d6b040149 /guix-data-service/web
parent11ec8a806494047589f119b0db2af862e1c41ae2 (diff)
downloaddata-service-f1418c4e88e9fc77e9a450fa1c01471e897774f3.tar
data-service-f1418c4e88e9fc77e9a450fa1c01471e897774f3.tar.gz
Support querying package derivation outputs without the nars
Since this speeds up the response if you don't need the nar information.
Diffstat (limited to 'guix-data-service/web')
-rw-r--r--guix-data-service/web/repository/controller.scm2
-rw-r--r--guix-data-service/web/revision/controller.scm12
-rw-r--r--guix-data-service/web/revision/html.scm25
-rw-r--r--guix-data-service/web/util.scm9
4 files changed, 45 insertions, 3 deletions
diff --git a/guix-data-service/web/repository/controller.scm b/guix-data-service/web/repository/controller.scm
index aa31df6..752c424 100644
--- a/guix-data-service/web/repository/controller.scm
+++ b/guix-data-service/web/repository/controller.scm
@@ -398,6 +398,8 @@
#:default "any")
(system ,parse-system #:default "x86_64-linux")
(target ,parse-target #:default "")
+ (field ,identity #:multi-value
+ #:default ("nars"))
(limit_results ,parse-result-limit
#:no-default-when (all_results)
#:default 10)
diff --git a/guix-data-service/web/revision/controller.scm b/guix-data-service/web/revision/controller.scm
index 24d9188..7d6f047 100644
--- a/guix-data-service/web/revision/controller.scm
+++ b/guix-data-service/web/revision/controller.scm
@@ -267,6 +267,8 @@
#:default "any")
(system ,parse-system #:default "x86_64-linux")
(target ,parse-target #:default "")
+ (field ,identity #:multi-value
+ #:default ("nars"))
(limit_results ,parse-result-limit
#:no-default-when (all_results)
#:default 10)
@@ -1253,7 +1255,9 @@
(let ((limit-results
(assq-ref query-parameters 'limit_results))
(all-results
- (assq-ref query-parameters 'all_results)))
+ (assq-ref query-parameters 'all_results))
+ (fields
+ (assq-ref query-parameters 'field)))
(letpar&
((derivation-outputs
(with-thread-postgresql-connection
@@ -1270,6 +1274,7 @@
(assq-ref query-parameters 'output_consistency)
#:system (assq-ref query-parameters 'system)
#:target (assq-ref query-parameters 'target)
+ #:include-nars? (member "nars" fields)
#:limit-results limit-results
#:after-path (assq-ref query-parameters 'after_path))))))
(let ((show-next-page?
@@ -1287,6 +1292,11 @@
. ,(list->vector
(map (match-lambda
((package-name package-version
+ path hash-algorithm hash recursive)
+ `((package . ((name . ,package-name)
+ (version . ,package-version)))
+ (path . ,path)))
+ ((package-name package-version
path hash-algorithm hash recursive
nars)
`((package . ((name . ,package-name)
diff --git a/guix-data-service/web/revision/html.scm b/guix-data-service/web/revision/html.scm
index 4680874..eeb2fc8 100644
--- a/guix-data-service/web/revision/html.scm
+++ b/guix-data-service/web/revision/html.scm
@@ -1876,6 +1876,15 @@ figure {
(cons url id)))
build-server-urls))
+ (define field-options
+ (map
+ (lambda (field)
+ (cons field
+ (hyphenate-words
+ (remove-brackets
+ (string-downcase field)))))
+ '("(no additional fields)" "Nars")))
+
(layout
#:title
(string-append "Package derivation outputs - Revision "
@@ -1938,6 +1947,11 @@ figure {
#:help-text "Only include outputs from derivations that are build for this system."
#:font-family "monospace")
,(form-horizontal-control
+ "Fields" query-parameters
+ #:name "field"
+ #:options field-options
+ #:help-text "Fields to return in the response.")
+ ,(form-horizontal-control
"After path" query-parameters
#:help-text
"List outputs that are alphabetically after the given name.")
@@ -1977,12 +1991,19 @@ figure {
(thead
(tr
(th (@ (class "col-sm-5")) "Path")
- (th (@ (class "col-sm-5")) "Data")
- (th (@ (class "col-sm-2")) "Output consistency")))
+ ,@(if (member "nars" (assq-ref query-parameters 'field))
+ '((th (@ (class "col-sm-5")) "Data")
+ (th (@ (class "col-sm-2")) "Output consistency"))
+ '())))
(tbody
,@(map
(match-lambda
((package-name package-version
+ path hash-algorithm hash recursive)
+ `(tr
+ (td (a (@ (href ,path))
+ ,(display-store-item-short path)))))
+ ((package-name package-version
path hash-algorithm hash recursive nars)
`(tr
(td (a (@ (href ,path))
diff --git a/guix-data-service/web/util.scm b/guix-data-service/web/util.scm
index 439c581..1dd193a 100644
--- a/guix-data-service/web/util.scm
+++ b/guix-data-service/web/util.scm
@@ -28,6 +28,7 @@
directory?
hyphenate-words
+ remove-brackets
underscore-join-words))
(define (most-appropriate-mime-type accepted-mime-types
@@ -99,6 +100,14 @@
(string-split words #\space)
"-"))
+(define (remove-brackets s)
+ (string-filter
+ (lambda (c)
+ (not
+ (or (eq? #\( c)
+ (eq? #\) c))))
+ s))
+
(define (underscore-join-words words)
(string-join
(string-split words #\space)