summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-04-08 21:04:12 +0100
committerChristopher Baines <mail@cbaines.net>2019-04-08 21:04:12 +0100
commit6022edd0742460aab4f1476d8e91210b13b978c7 (patch)
tree125cba47578947f6951bc5539c7b7add78ce6d20
parent0c72ee747c253ea538032c6593683af6a54af5d3 (diff)
downloaddata-service-6022edd0742460aab4f1476d8e91210b13b978c7.tar
data-service-6022edd0742460aab4f1476d8e91210b13b978c7.tar.gz
Add a statistics page
To show the total number of derivations, and guix revisions.
-rw-r--r--guix-data-service/web/controller.scm4
-rw-r--r--guix-data-service/web/view/html.scm25
2 files changed, 29 insertions, 0 deletions
diff --git a/guix-data-service/web/controller.scm b/guix-data-service/web/controller.scm
index 0823c5f..2aa516d 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -293,6 +293,10 @@
(apply render-html
(view-builds (select-build-stats conn)
(select-builds-with-context conn))))
+ ((GET "statistics")
+ (apply render-html
+ (view-statistics (count-guix-revisions conn)
+ (count-derivations conn))))
((GET "revision" commit-hash)
(apply render-html
(view-revision commit-hash
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index 2be4b22..0122504 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -26,6 +26,7 @@
#:use-module (texinfo)
#:use-module (texinfo html)
#:export (index
+ view-statistics
view-revision-package-and-version
view-revision
view-revision-packages
@@ -188,6 +189,30 @@
(td ,source))))
queued-guix-revisions))))))))))
+
+(define (view-statistics guix-revisions-count derivations-count)
+ (layout
+ #:extra-headers
+ '((cache-control . ((max-age . 60))))
+ #:body
+ `(,(header)
+ (div
+ (@ (class "container"))
+ (div
+ (@ (class "row"))
+ (div
+ (@ (class "col-md-6"))
+ (h3 "Guix revisions")
+ (strong (@ (class "text-center")
+ (style "font-size: 2em; display: block;"))
+ ,guix-revisions-count))
+ (div
+ (@ (class "col-md-6"))
+ (h3 "Derivations")
+ (strong (@ (class "text-center")
+ (style "font-size: 2em; display: block;"))
+ ,derivations-count)))))))
+
(define (view-revision-package-and-version revision-commit-hash name version
package-metadata
derivations)