diff --git a/app/__init__.py b/app/__init__.py index 0498cc5..1e60430 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -25,4 +25,7 @@ def create_app(): auth.init_app(app) app.register_blueprint(auth.blueprint) + from . import stats + app.register_blueprint(stats.blueprint) + return app diff --git a/app/stats.py b/app/stats.py new file mode 100644 index 0000000..f003bb4 --- /dev/null +++ b/app/stats.py @@ -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 + ) diff --git a/app/templates/stats.html b/app/templates/stats.html new file mode 100644 index 0000000..b327bc7 --- /dev/null +++ b/app/templates/stats.html @@ -0,0 +1,9 @@ +{% extends "_skel.html" %} +{% block title %}Stats{% endblock %} +{% block content %} +
Total accomplishments added: {{ total }}
+ Without mine: {{ total_without_mine }}
+ Registered users: {{ total_users }}