Skip to content

Commit

Permalink
ADD: More statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKaschta committed Oct 21, 2024
1 parent e70413a commit 2c79815
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion nanposweb/admin/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ def index():

results.append({"product": product, "count": maximum, "users": users})

return render_template('statistics/index.html', results=results)
total_balance = Revenue.query.with_entities(func.sum(Revenue.amount).label('total')).first().total
total_user_count = User.query.with_entities(func.count(User.id)).scalar()
total_product_count = Product.query.with_entities(func.count(Product.id)).scalar()

return render_template('statistics/index.html', results=results, total_balance=total_balance,
total_user_count=total_user_count, total_product_count=total_product_count)
4 changes: 3 additions & 1 deletion nanposweb/admin/templates/statistics/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
{% block pagetitle %}Statistics{% endblock %}

{% block content %}

<p><b>Total user count:</b> {{ total_user_count }}</p>
<p><b>Total product count:</b> {{ total_product_count }}</p>
<p><b>Total outstanding balance:</b> {{ total_balance | format_currency }}</p>
<table class="table">
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "nanposweb"
description = "A simple point of sale system for drinks"
requires-python= ">=3.9"
license = {text = "MIT"}
version = "1.3.0"
version = "1.3.1"
dependencies = [
"Flask==2.2.3",
"Flask-SQLAlchemy",
Expand Down

0 comments on commit 2c79815

Please sign in to comment.