display total hat sales in /hats

master
Aevann1 2022-09-04 00:32:46 +02:00
parent 90d32b1381
commit 038452f9a6
2 changed files with 3 additions and 1 deletions

View File

@ -21,7 +21,8 @@ def hats(v):
not_owned = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.notin_(owned_hat_ids)).order_by(HatDef.price, HatDef.name).all() not_owned = g.db.query(HatDef, User).join(HatDef.author).filter(HatDef.id.notin_(owned_hat_ids)).order_by(HatDef.price, HatDef.name).all()
hats = owned + not_owned hats = owned + not_owned
return render_template("hats.html", owned_hat_ids=owned_hat_ids, hats=hats, v=v) sales = g.db.query(func.sum(User.coins_spent_on_hats)).scalar()
return render_template("hats.html", owned_hat_ids=owned_hat_ids, hats=hats, v=v, sales=sales)
@app.post("/buy_hat/<hat_id>") @app.post("/buy_hat/<hat_id>")
@auth_required @auth_required

View File

@ -12,6 +12,7 @@
<h5 class="mt-4">Number of hats you bought: {{v.num_of_owned_hats}}</h5> <h5 class="mt-4">Number of hats you bought: {{v.num_of_owned_hats}}</h5>
<h5 class="mt-4">Number of hats you designed: {{v.num_of_designed_hats}}</h5> <h5 class="mt-4">Number of hats you designed: {{v.num_of_designed_hats}}</h5>
<h5 class="mt-4">Coins you spent on hats: {{v.coins_spent_on_hats}}</h5> <h5 class="mt-4">Coins you spent on hats: {{v.coins_spent_on_hats}}</h5>
<h5 class="mt-4">Total hat sales: {{sales}}</h5>
</header> </header>
{% endblock %} {% endblock %}