2019-09-10 02:50:22 +02:00
|
|
|
"Script to generate the stats related views of Haldis"
|
2019-08-28 03:46:04 +02:00
|
|
|
from flask import Blueprint
|
|
|
|
from flask import current_app as app
|
2016-09-10 15:49:52 +02:00
|
|
|
from flask import render_template
|
|
|
|
|
2020-02-26 21:33:41 +01:00
|
|
|
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-08-28 03:46:04 +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)
|