From 8b24da46f4f8b40e773e8200f67421557b295bde Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 14 Jan 2021 14:50:20 -0800 Subject: [PATCH] fix stats page and double-checking the same info --- app/models.py | 7 +++++++ app/routes/meta.py | 8 +++++++- app/templates/stats.html | 13 ++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/models.py b/app/models.py index ec48231..58be233 100644 --- a/app/models.py +++ b/app/models.py @@ -60,6 +60,13 @@ class Operation(db.Model): } return pricing + def has_txes(self): + txes = cache.get_transfers(self.account_idx) + if txes: + return True + else: + return False + def __repr__(self): return self.id diff --git a/app/routes/meta.py b/app/routes/meta.py index 8a82b2b..fa9e8dc 100644 --- a/app/routes/meta.py +++ b/app/routes/meta.py @@ -30,9 +30,15 @@ def info(): @bp.route('/stats') def stats(): token = config.STATS_TOKEN == request.args.get('token') + all_ops = {'active': [], 'inactive': []} ops = Operation.query.all() + for op in ops: + if op.has_txes(): + all_ops['active'].append(op) + else: + all_ops['inactive'].append(op) return render_template( 'stats.html', - ops=ops, + all_ops=all_ops, token=token ) diff --git a/app/templates/stats.html b/app/templates/stats.html index ece9096..99c8399 100644 --- a/app/templates/stats.html +++ b/app/templates/stats.html @@ -13,7 +13,7 @@ {% if token %}

Paid Ops


- {% if ops %} + {% if all_ops %} @@ -23,11 +23,10 @@ - {% for op in ops | sort(attribute='create_date', reverse=True) %} + {% for op in all_ops['active'] | sort(attribute='create_date', reverse=True) %} {% set balances = op.get_balances() %} {% set unlocked = balances['unlocked'] | from_atomic_xmr %} {% set locked = (balances['balance'] - balances['unlocked']) | from_atomic_xmr %} - {% if balances['balance'] > 0 %} @@ -36,17 +35,13 @@ - - {% endif %} {% endfor %}
DateVolume ID Balances
{{ op.create_date }} {{ op.codename }}{{ op.volume_id }} {{ unlocked }} XMR ({{ locked }} locked)

Unpaid Ops

{% endif %}