aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-19 22:31:07 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-19 22:31:07 +0100
commit6add08b1094ed13c4dfab6a7609bb3a5099abe9e (patch)
treecbee09374105197b877caaf19db5b8c9b4f437cb /guix-data-service/web
parentcc0ecdc055082a0adbefe3d7e0d2e5a05416e890 (diff)
downloaddata-service-6add08b1094ed13c4dfab6a7609bb3a5099abe9e.tar
data-service-6add08b1094ed13c4dfab6a7609bb3a5099abe9e.tar.gz
Add missing revision handling
As previously the pages would render, but with no data.
Diffstat (limited to 'guix-data-service/web')
-rw-r--r--guix-data-service/web/controller.scm86
-rw-r--r--guix-data-service/web/view/html.scm14
2 files changed, 71 insertions, 29 deletions
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 81093ef..79f2848 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -131,6 +131,22 @@
(sxml->html (stexi->shtml stexi)))))
(plain . ,(stexi->plain-text stexi)))))
+(define (render-unknown-revision mime-types conn commit-hash)
+ (case (most-appropriate-mime-type
+ '(application/json text/html)
+ mime-types)
+ ((application/json)
+ (render-json
+ '((unknown_commit . ,commit-hash))
+ #:code 404))
+ (else
+ (render-html
+ #:code 404
+ #:sxml (unknown-revision
+ commit-hash
+ (select-job-for-commit
+ conn commit-hash))))))
+
(define (render-revision-packages mime-types
conn
commit-hash
@@ -552,37 +568,49 @@
(render-html
#:sxml (view-statistics (count-guix-revisions conn)
(count-derivations conn))))
- ((GET "revision" commit-hash) (render-view-revision mime-types
- conn
- commit-hash))
+ ((GET "revision" commit-hash) (if (guix-commit-exists? conn commit-hash)
+ (render-view-revision mime-types
+ conn
+ commit-hash)
+ (render-unknown-revision mime-types
+ conn
+ commit-hash)))
((GET "revision" commit-hash "packages")
- (let ((parsed-query-parameters
- (guard-against-mutually-exclusive-query-parameters
- (parse-query-parameters
- request
- `((after_name ,identity)
- (field ,identity #:multi-value
- #:default ("version" "synopsis"))
- (search_query ,identity)
- (limit_results ,parse-result-limit
- #:no-default-when (all_results)
- #:default 100)
- (all_results ,parse-checkbox-value)))
- ;; You can't specify a search query, but then also limit the
- ;; results by filtering for after a particular package name
- '((after_name search_query)
- (limit_results all_results)))))
+ (if (guix-commit-exists? conn commit-hash)
+ (let ((parsed-query-parameters
+ (guard-against-mutually-exclusive-query-parameters
+ (parse-query-parameters
+ request
+ `((after_name ,identity)
+ (field ,identity #:multi-value
+ #:default ("version" "synopsis"))
+ (search_query ,identity)
+ (limit_results ,parse-result-limit
+ #:no-default-when (all_results)
+ #:default 100)
+ (all_results ,parse-checkbox-value)))
+ ;; You can't specify a search query, but then also limit the
+ ;; results by filtering for after a particular package name
+ '((after_name search_query)
+ (limit_results all_results)))))
- (render-revision-packages mime-types
- conn
- commit-hash
- parsed-query-parameters)))
- ((GET "revision" commit-hash "package" name version) (render-revision-package
- mime-types
- conn
- commit-hash
- name
- version))
+ (render-revision-packages mime-types
+ conn
+ commit-hash
+ parsed-query-parameters))
+ (render-unknown-revision mime-types
+ conn
+ commit-hash)))
+ ((GET "revision" commit-hash "package" name version)
+ (if (guix-commit-exists? conn commit-hash)
+ (render-revision-package mime-types
+ conn
+ commit-hash
+ name
+ version)
+ (render-unknown-revision mime-types
+ conn
+ commit-hash)))
((GET "branches")
(render-html
#:sxml (view-branches
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index 9d87548..0a9aabb 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -29,6 +29,7 @@
#:use-module (texinfo html)
#:use-module (json)
#:export (index
+ unknown-revision
view-statistics
view-revision-package-and-version
view-revision
@@ -1388,6 +1389,19 @@
(take data 2))
(vlist->list target-packages-vhash))))))))))))
+(define (unknown-revision commit-hash job)
+ (layout
+ #:body
+ `(,(header)
+ (div
+ (@ (class "container"))
+ (h1 "Unknown revision")
+ (p "No known revision with commit "
+ (strong (samp ,commit-hash))
+ ,(if job
+ " and it is not currently queued for processing"
+ " but it is queued for processing"))))))
+
(define (compare-unknown-commit base-commit target-commit
base-exists? target-exists?
base-job target-job)