add a new stats page
This commit is contained in:
@@ -287,6 +287,21 @@ def profile():
|
|||||||
context = default_context()
|
context = default_context()
|
||||||
return render_template('profile.html', **context)
|
return render_template('profile.html', **context)
|
||||||
|
|
||||||
|
@app.route('/stats')
|
||||||
|
def stats():
|
||||||
|
context = default_context()
|
||||||
|
mdb = get_metas()
|
||||||
|
kv = {k:v for k,v in mdb.items()} # read all of metas to memory at once, for efficiency
|
||||||
|
tstr = lambda t: time.strftime('%b %d %Y', time.localtime(t))
|
||||||
|
context['num_papers'] = len(kv)
|
||||||
|
if len(kv) > 0:
|
||||||
|
context['earliest_paper'] = tstr(min(kv.values(), key=lambda x: x['_time'])['_time'])
|
||||||
|
context['latest_paper'] = tstr(max(kv.values(), key=lambda x: x['_time'])['_time'])
|
||||||
|
else:
|
||||||
|
context['earliest_paper'] = 'N/A'
|
||||||
|
context['latest_paper'] = 'N/A'
|
||||||
|
return render_template('stats.html', **context)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# tag related endpoints: add, delete tags for any paper
|
# tag related endpoints: add, delete tags for any paper
|
||||||
|
|
||||||
|
|||||||
+15
-7
@@ -4,7 +4,6 @@ body {
|
|||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
height: 24px;
|
height: 24px;
|
||||||
background-color: #844;
|
background-color: #844;
|
||||||
@@ -13,6 +12,17 @@ body {
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
border-bottom: 1px solid #622;
|
border-bottom: 1px solid #622;
|
||||||
}
|
}
|
||||||
|
#home-link {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
#stats-link {
|
||||||
|
float: right;
|
||||||
|
margin: 0 10px 0 10px;
|
||||||
|
}
|
||||||
|
#login-link {
|
||||||
|
float: right;
|
||||||
|
margin: 0 10px 0 10px;
|
||||||
|
}
|
||||||
#controls {
|
#controls {
|
||||||
margin: 10px 40px 0 40px;
|
margin: 10px 40px 0 40px;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
@@ -178,12 +188,6 @@ body {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
#login-link {
|
|
||||||
/* position on the right of the header */
|
|
||||||
position: absolute;
|
|
||||||
right: 10px;
|
|
||||||
top: 10px;
|
|
||||||
}
|
|
||||||
#profile-warning {
|
#profile-warning {
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@@ -234,3 +238,7 @@ body {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
#statswrap {
|
||||||
|
margin: 10px 40px 0 40px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|||||||
+2
-1
@@ -20,10 +20,11 @@ var user = {{ user | tojson }};
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<a href="/">arxiv-sanity</a>
|
<a href="/" id="home-link">arxiv-sanity</a>
|
||||||
<a href="/profile" id="login-link">
|
<a href="/profile" id="login-link">
|
||||||
{{ 'profile' if user else 'login' }}
|
{{ 'profile' if user else 'login' }}
|
||||||
</a>
|
</a>
|
||||||
|
<a href="/stats" id="stats-link">stats</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block variables %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div id="statswrap">
|
||||||
|
<div><b>Current database index:</b></div>
|
||||||
|
<div>Number of papers: {{ num_papers }}</div>
|
||||||
|
<div>Earliest paper: {{ earliest_paper }}</div>
|
||||||
|
<div>Latest paper: {{ latest_paper }}</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block elements %}
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user