diff options
author | Christopher Baines <mail@cbaines.net> | 2020-02-13 23:11:59 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-02-13 23:11:59 +0000 |
commit | 374dc25440efaef619cdc8d3288261c20ce45858 (patch) | |
tree | ed44f30245828ce3e54e225f0a3f70dab570fad8 /guix-data-service | |
parent | dfccbf911c7badfdffc96398d0967e86a55da80e (diff) | |
download | data-service-374dc25440efaef619cdc8d3288261c20ce45858.tar data-service-374dc25440efaef619cdc8d3288261c20ce45858.tar.gz |
Improve system and target query parameter handling
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/model/derivation.scm | 3 | ||||
-rw-r--r-- | guix-data-service/web/compare/controller.scm | 7 | ||||
-rw-r--r-- | guix-data-service/web/query-parameters.scm | 19 | ||||
-rw-r--r-- | guix-data-service/web/revision/controller.scm | 24 | ||||
-rw-r--r-- | guix-data-service/web/view/html.scm | 19 |
5 files changed, 50 insertions, 22 deletions
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm index de675d5..849f6cb 100644 --- a/guix-data-service/model/derivation.scm +++ b/guix-data-service/model/derivation.scm @@ -68,8 +68,7 @@ "x86_64-linux")) (define (valid-targets conn) - '("" ;; no target - "arm-linux-gnueabihf" + '("arm-linux-gnueabihf" "aarch64-linux-gnu" "powerpc-linux-gnu" "riscv64-linux-gnu" diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index c19b253..78ed3fa 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -44,9 +44,6 @@ . (public (max-age . ,cache-control-default-max-age))))) -(define (parse-system s) - s) - (define (parse-build-status s) s) @@ -106,7 +103,7 @@ `((base_commit ,(parse-commit conn) #:required) (target_commit ,(parse-commit conn) #:required) (system ,parse-system #:multi-value) - (target ,parse-system #:multi-value) + (target ,parse-target #:multi-value) (build_status ,parse-build-status #:multi-value))))) (render-compare/derivations mime-types conn @@ -121,7 +118,7 @@ (target_branch ,identity #:required) (target_datetime ,parse-datetime #:required) (system ,parse-system #:multi-value) - (target ,parse-system #:multi-value) + (target ,parse-target #:multi-value) (build_status ,parse-build-status #:multi-value))) '((base_commit base_datetime) (target_commit target_datetime))))) diff --git a/guix-data-service/web/query-parameters.scm b/guix-data-service/web/query-parameters.scm index c12a490..6679711 100644 --- a/guix-data-service/web/query-parameters.scm +++ b/guix-data-service/web/query-parameters.scm @@ -42,7 +42,11 @@ parse-datetime parse-checkbox-value parse-number - parse-result-limit)) + parse-result-limit + parse-system + parse-target + + valid-targets->options)) (define (parse-query-string query) "Parse and decode the URI query string QUERY and return an alist." @@ -219,6 +223,19 @@ (define parse-result-limit parse-number) +(define parse-system identity) + +(define (parse-target target) + (if (string=? target "none") + "" + target)) + +(define (valid-targets->options targets) + `(("" . "none") + ,@(map (lambda (target) + (cons target target)) + targets))) + (define (any-invalid-query-parameters? query-parameters) (->bool (any (lambda (val) (if (list? val) diff --git a/guix-data-service/web/revision/controller.scm b/guix-data-service/web/revision/controller.scm index 0815356..8fb616d 100644 --- a/guix-data-service/web/revision/controller.scm +++ b/guix-data-service/web/revision/controller.scm @@ -64,9 +64,6 @@ . (public (max-age . ,cache-control-default-max-age))))) -(define (parse-system s) - s) - (define (parse-build-status status) (if (member status build-status-strings) status @@ -173,7 +170,7 @@ request `((search_query ,identity) (system ,parse-system #:multi-value) - (target ,identity #:multi-value) + (target ,parse-target #:multi-value) (maximum_builds ,parse-number) (minimum_builds ,parse-number) (after_name ,identity) @@ -202,7 +199,7 @@ (output_consistency ,identity #:default "any") (system ,parse-system #:default "x86_64-linux") - (target ,identity) + (target ,parse-target) (limit_results ,parse-result-limit #:no-default-when (all_results) #:default 10) @@ -252,7 +249,7 @@ `((build_status ,parse-build-status #:multi-value) (build_server ,(parse-build-server conn) #:multi-value) (system ,parse-system #:default "x86_64-linux") - (target ,identity))))) + (target ,parse-target))))) (render-revision-builds mime-types conn @@ -698,7 +695,8 @@ #:sxml (view-revision-derivations commit-hash query-parameters (valid-systems conn) - (valid-targets conn) + (valid-targets->options + (valid-targets conn)) '() '() #f @@ -755,7 +753,8 @@ #:sxml (view-revision-derivations commit-hash query-parameters (valid-systems conn) - (valid-targets conn) + (valid-targets->options + (valid-targets conn)) derivations build-server-urls show-next-page? @@ -830,7 +829,8 @@ derivation-outputs build-server-urls (valid-systems conn) - (valid-targets conn) + (valid-targets->options + (valid-targets conn)) show-next-page? #:path-base path-base #:header-text header-text @@ -852,7 +852,8 @@ commit-hash build-status-strings (valid-systems conn) - (valid-targets conn) + (valid-targets->options + (valid-targets conn)) '() '() '())) @@ -863,7 +864,8 @@ commit-hash build-status-strings (valid-systems conn) - (valid-targets conn) + (valid-targets->options + (valid-targets conn)) (map (match-lambda ((id url lookup-all-derivations) (cons url id))) diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm index 4c1c9ce..e45a67a 100644 --- a/guix-data-service/web/view/html.scm +++ b/guix-data-service/web/view/html.scm @@ -104,7 +104,8 @@ options (allow-selecting-multiple-options #t) font-family - (type "text")) + (type "text") + (null-string-value "none")) (define (value->text value) (match value (#f "") @@ -163,14 +164,26 @@ (map (match-lambda ((option-label . option-value) `(option - (@ ,@(if (member option-value selected-options) + (@ ,@(if (member (if (and + (string? option-value) + (string=? option-value + null-string-value)) + "" + option-value) + selected-options) '((selected "")) '()) (value ,option-value)) ,(value->text option-label))) (option-value `(option - (@ ,@(if (member option-value selected-options) + (@ ,@(if (member (if (and + (string? option-value) + (string=? option-value + null-string-value)) + "" + option-value) + selected-options) '((selected "")) '())) ,(value->text option-value)))) |