haldis/app/views/stats.py

23 lines
653 B
Python
Raw Normal View History

2019-09-10 02:50:22 +02:00
"Script to generate the stats related views of Haldis"
from flask import Blueprint
from flask import current_app as app
2016-09-10 15:49:52 +02:00
from flask import render_template
from fatmodels import FatLocation, FatOrder, FatOrderItem, FatUser
2016-09-10 16:52:46 +02:00
2019-09-05 03:33:29 +02:00
stats_blueprint = Blueprint("stats_blueprint", __name__)
2016-09-10 15:49:52 +02:00
2019-09-05 03:33:29 +02:00
@stats_blueprint.route("/")
2019-09-08 01:34:16 +02:00
def stats() -> str:
2019-09-10 02:50:22 +02:00
"Generate Haldis data in a pretty format"
2016-09-10 16:52:46 +02:00
data = {
2019-09-05 03:33:29 +02:00
"amount": {
"orders": FatOrder.amount(),
"locations": FatLocation.amount(),
"users": FatUser.amount(),
"orderitems": FatOrderItem.amount(),
2016-09-10 23:01:13 +02:00
}
2016-09-10 16:52:46 +02:00
}
2019-09-05 03:33:29 +02:00
return render_template("stats.html", data=data)