add few more stats
This commit is contained in:
parent
1769b7b02f
commit
5990a938a4
12
serve.py
12
serve.py
@ -302,14 +302,22 @@ 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
|
||||
times = [v['_time'] for v in kv.values()]
|
||||
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'])
|
||||
context['earliest_paper'] = tstr(min(times))
|
||||
context['latest_paper'] = tstr(max(times))
|
||||
else:
|
||||
context['earliest_paper'] = 'N/A'
|
||||
context['latest_paper'] = 'N/A'
|
||||
|
||||
# count number of papers from various time deltas to now
|
||||
tnow = time.time()
|
||||
for thr in [1, 6, 12, 24, 48, 72, 96]:
|
||||
context['thr_%d' % thr] = len([t for t in times if t > tnow - thr*60*60])
|
||||
|
||||
return render_template('stats.html', **context)
|
||||
|
||||
@app.route('/about')
|
||||
|
||||
@ -5,10 +5,24 @@
|
||||
|
||||
{% block content %}
|
||||
<div id="statswrap">
|
||||
<div><b>Current database index:</b></div>
|
||||
<div>Number of papers: {{ num_papers }}</div>
|
||||
|
||||
<div><b>Current index:</b></div>
|
||||
<div>Number of papers total: {{ num_papers }}</div>
|
||||
<div>Earliest paper: {{ earliest_paper }}</div>
|
||||
<div>Latest paper: {{ latest_paper }}</div>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- thresholds are [1, 6, 12, 24, 48, 72, 96] -->
|
||||
<div><b>New paper counts flow:</b></div>
|
||||
<div>Number of new papers in the last 1 hour : {{ thr_1 }}</div>
|
||||
<div>Number of new papers in the last 6 hours: {{ thr_6 }}</div>
|
||||
<div>Number of new papers in the last 12 hours: {{ thr_12 }}</div>
|
||||
<div>Number of new papers in the last 24 hours: {{ thr_24 }}</div>
|
||||
<div>Number of new papers in the last 48 hours: {{ thr_48 }}</div>
|
||||
<div>Number of new papers in the last 72 hours: {{ thr_72 }}</div>
|
||||
<div>Number of new papers in the last 96 hours: {{ thr_96 }}</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user