fix stats page and double-checking the same info

pull/1/head
lza_menace 4 years ago
parent 2664a658df
commit 8b24da46f4

@ -60,6 +60,13 @@ class Operation(db.Model):
} }
return pricing return pricing
def has_txes(self):
txes = cache.get_transfers(self.account_idx)
if txes:
return True
else:
return False
def __repr__(self): def __repr__(self):
return self.id return self.id

@ -30,9 +30,15 @@ def info():
@bp.route('/stats') @bp.route('/stats')
def stats(): def stats():
token = config.STATS_TOKEN == request.args.get('token') token = config.STATS_TOKEN == request.args.get('token')
all_ops = {'active': [], 'inactive': []}
ops = Operation.query.all() 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( return render_template(
'stats.html', 'stats.html',
ops=ops, all_ops=all_ops,
token=token token=token
) )

@ -13,7 +13,7 @@
{% if token %} {% if token %}
<h1>Paid Ops</h1> <h1>Paid Ops</h1>
<br /> <br />
{% if ops %} {% if all_ops %}
<table class="table center"> <table class="table center">
<tr> <tr>
<th>Date</th> <th>Date</th>
@ -23,11 +23,10 @@
<th>Volume ID</th> <th>Volume ID</th>
<th>Balances</th> <th>Balances</th>
</tr> </tr>
{% 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 balances = op.get_balances() %}
{% set unlocked = balances['unlocked'] | from_atomic_xmr %} {% set unlocked = balances['unlocked'] | from_atomic_xmr %}
{% set locked = (balances['balance'] - balances['unlocked']) | from_atomic_xmr %} {% set locked = (balances['balance'] - balances['unlocked']) | from_atomic_xmr %}
{% if balances['balance'] > 0 %}
<tr> <tr>
<td>{{ op.create_date }}</td> <td>{{ op.create_date }}</td>
<td><a href="{{ url_for('operation.view_operation', id=op.id) }}" target="_blank">{{ op.codename }}</a></td> <td><a href="{{ url_for('operation.view_operation', id=op.id) }}" target="_blank">{{ op.codename }}</a></td>
@ -36,17 +35,13 @@
<td>{{ op.volume_id }}</td> <td>{{ op.volume_id }}</td>
<td>{{ unlocked }} XMR ({{ locked }} locked)</td> <td>{{ unlocked }} XMR ({{ locked }} locked)</td>
</tr> </tr>
{% endif %}
{% endfor %} {% endfor %}
</table> </table>
<h1>Unpaid Ops</h1> <h1>Unpaid Ops</h1>
<ul> <ul>
{% for op in ops %} {% for op in all_ops['inactive'] %}
{% if op.get_balances()['balance'] == 0 %}
<li>{{ op.create_date }} - <a class="is-link" href="{{ url_for('operation.view_operation', id=op.id) }}">{{ op.id }}</a> - {{ op.codename }} - {{ op.account_idx }}</li> <li>{{ op.create_date }} - <a class="is-link" href="{{ url_for('operation.view_operation', id=op.id) }}">{{ op.id }}</a> - {{ op.codename }} - {{ op.account_idx }}</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}

Loading…
Cancel
Save