add statistics
This commit is contained in:
parent
20849b8ee5
commit
1ec4f14a4a
|
|
@ -25,4 +25,7 @@ def create_app():
|
||||||
auth.init_app(app)
|
auth.init_app(app)
|
||||||
app.register_blueprint(auth.blueprint)
|
app.register_blueprint(auth.blueprint)
|
||||||
|
|
||||||
|
from . import stats
|
||||||
|
app.register_blueprint(stats.blueprint)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
from flask import Blueprint, render_template
|
||||||
|
from .db import db, Accomplishment, User
|
||||||
|
|
||||||
|
blueprint = Blueprint('stats', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@blueprint.route('/stats')
|
||||||
|
def stats():
|
||||||
|
total_accomplishments = Accomplishment.query.count()
|
||||||
|
total_accomplishments_by_me = Accomplishment.query.filter_by(
|
||||||
|
user_id=1).count()
|
||||||
|
total_users = User.query.count()
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
'stats.html',
|
||||||
|
total=total_accomplishments,
|
||||||
|
total_without_mine=total_accomplishments - total_accomplishments_by_me,
|
||||||
|
total_users=total_users
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends "_skel.html" %}
|
||||||
|
{% block title %}Stats{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="max-w-lg mx-auto text-center card">
|
||||||
|
<p><b>Total accomplishments added:</b> {{ total }}<br>
|
||||||
|
<b>Without mine:</b> {{ total_without_mine }}<br>
|
||||||
|
<b>Registered users:</b> {{ total_users }}</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Reference in New Issue