haldis/app/views/stats.py
Midgard d5bb14d3a5
Update views with HLDS models
Not expected to work yet, but if I don't do this generating migrations
gives errors.
2020-01-26 16:14:23 +01:00

23 lines
704 B
Python

"Script to generate the stats related views of Haldis"
from flask import Blueprint
from flask import current_app as app
from flask import render_template
from fatmodels import FatLocation, FatOrder, FatOrderItem, FatDish, FatUser
stats_blueprint = Blueprint("stats_blueprint", __name__)
@stats_blueprint.route("/")
def stats() -> str:
"Generate Haldis data in a pretty format"
data = {
"amount": {
"orders": FatOrder.amount(),
"locations": FatLocation.amount(),
"users": FatUser.amount(),
"orderitems": FatOrderItem.amount(),
"products": FatDish.amount(),
}
}
return render_template("stats.html", data=data)