rework stats a bit
parent
54fadc48d4
commit
74457e5468
|
@ -42,8 +42,8 @@ def cron(every_5m, every_1h, every_1d, every_1mo):
|
||||||
if every_1d:
|
if every_1d:
|
||||||
stats.generate_charts_task(SITE)
|
stats.generate_charts_task(SITE)
|
||||||
_sub_inactive_purge_task()
|
_sub_inactive_purge_task()
|
||||||
cache.delete_memoized(route_static.stats_cached)
|
stats = statshelper.stats(SITE_NAME)
|
||||||
route_static.stats_cached()
|
cache.set(f'{SITE}_stats', stats)
|
||||||
|
|
||||||
if every_1mo:
|
if every_1mo:
|
||||||
if KOFI_LINK: _give_monthly_marseybux_task_kofi()
|
if KOFI_LINK: _give_monthly_marseybux_task_kofi()
|
||||||
|
|
|
@ -84,12 +84,9 @@ def sidebar(v:Optional[User]):
|
||||||
@app.get("/stats")
|
@app.get("/stats")
|
||||||
@auth_required
|
@auth_required
|
||||||
def participation_stats(v:User):
|
def participation_stats(v:User):
|
||||||
if v.client: return stats_cached()
|
stats = cache.get(f'{SITE}_stats') or {}
|
||||||
return render_template("stats.html", v=v, title="Content Statistics", data=stats_cached())
|
if v.client: return stats
|
||||||
|
return render_template("stats.html", v=v, title="Content Statistics", data=stats)
|
||||||
@cache.memoize(timeout=864000)
|
|
||||||
def stats_cached():
|
|
||||||
return statshelper.stats(SITE_NAME)
|
|
||||||
|
|
||||||
@app.get("/chart")
|
@app.get("/chart")
|
||||||
def chart():
|
def chart():
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
<th>Value</th>
|
<th>Value</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for entry in data %}
|
{% for key, value in data.items() %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{entry}}</td>
|
<td>{{key}}</td>
|
||||||
<td>{{data[entry]}}</td>
|
<td>{{value}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue