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
def has_txes(self):
txes = cache.get_transfers(self.account_idx)
if txes:
return True
else:
return False
def __repr__(self):
return self.id

@ -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
)

@ -13,7 +13,7 @@
{% if token %}
<h1>Paid Ops</h1>
<br />
{% if ops %}
{% if all_ops %}
<table class="table center">
<tr>
<th>Date</th>
@ -23,11 +23,10 @@
<th>Volume ID</th>
<th>Balances</th>
</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 unlocked = balances['unlocked'] | from_atomic_xmr %}
{% set locked = (balances['balance'] - balances['unlocked']) | from_atomic_xmr %}
{% if balances['balance'] > 0 %}
<tr>
<td>{{ op.create_date }}</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>{{ unlocked }} XMR ({{ locked }} locked)</td>
</tr>
{% endif %}
{% endfor %}
</table>
<h1>Unpaid Ops</h1>
<ul>
{% for op in ops %}
{% 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>
{% endif %}
{% for op in all_ops['inactive'] %}
<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>
{% endfor %}
</ul>
{% endif %}

Loading…
Cancel
Save