aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-06-25 10:46:21 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-06-25 10:46:21 -0700
commitde3eefb2125c22661950ce21c2524b83e0688ea8 (patch)
treece647ebdb732bd179fcc4365729ac594a0e5011d
parent3d53a6f8d3e42de68f0c142b2d1329a66a0b7924 (diff)
downloadfatcat-de3eefb2125c22661950ce21c2524b83e0688ea8.tar.gz
fatcat-de3eefb2125c22661950ce21c2524b83e0688ea8.zip
stats page
-rw-r--r--python/fatcat/routes.py5
-rw-r--r--python/fatcat/templates/stats.html104
-rw-r--r--python/tests/routes.py3
3 files changed, 112 insertions, 0 deletions
diff --git a/python/fatcat/routes.py b/python/fatcat/routes.py
index 8fe74a2d..77aecff3 100644
--- a/python/fatcat/routes.py
+++ b/python/fatcat/routes.py
@@ -156,6 +156,11 @@ def editor_changelog(username):
return render_template('editor_changelog.html', editor=editor,
changelog_entries=changelog_entries)
+@app.route('/stats', methods=['GET'])
+def stats_view():
+ stats = api.get_stats()
+ return render_template('stats.html', stats=stats.extra)
+
### Search ##################################################################
@app.route('/release/search', methods=['GET', 'POST'])
diff --git a/python/fatcat/templates/stats.html b/python/fatcat/templates/stats.html
new file mode 100644
index 00000000..6a37dcee
--- /dev/null
+++ b/python/fatcat/templates/stats.html
@@ -0,0 +1,104 @@
+{% extends "base.html" %}
+{% block body %}
+
+<h1>Entity Statistics</h1>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.entity_counts.work }}
+ </div>
+ <div class="label">
+ Works
+ </div>
+</div>
+
+<br>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.entity_counts.release }}
+ </div>
+ <div class="label">
+ Releases
+ </div>
+</div>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.releases_with_dois }}
+ </div>
+ <div class="label">
+ ... with DOIs
+ </div>
+</div>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.releases_with_dois }}
+ </div>
+ <div class="label">
+ ... with a File
+ </div>
+</div>
+
+<br>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.entity_counts.container }}
+ </div>
+ <div class="label">
+ Containers
+ </div>
+</div>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.containers_with_issnls }}
+ </div>
+ <div class="label">
+ ... with an ISSN-L
+ </div>
+</div>
+
+<br>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.entity_counts.creator }}
+ </div>
+ <div class="label">
+ Creators
+ </div>
+</div>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.creators_with_orcids }}
+ </div>
+ <div class="label">
+ ... with an ORCID
+ </div>
+</div>
+
+<br>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.entity_counts.file }}
+ </div>
+ <div class="label">
+ Files
+ </div>
+</div>
+
+<div class="ui statistic">
+ <div class="value">
+ {{ stats.files_with_releases }}
+ </div>
+ <div class="label">
+ ... with a Release
+ </div>
+</div>
+
+{% endblock %}
diff --git a/python/tests/routes.py b/python/tests/routes.py
index f92df54c..ec4eaf12 100644
--- a/python/tests/routes.py
+++ b/python/tests/routes.py
@@ -88,3 +88,6 @@ def test_all_views(app):
rv = app.get('/editor/admin/changelog')
assert rv.status_code == 200
+
+ rv = app.get('/stats')
+ assert rv.status_code == 200