Better stats display

feature/cython
informatic 2017-06-02 14:59:02 +02:00
parent 4e8e085587
commit 55dab93eb8
2 changed files with 21 additions and 2 deletions

View File

@ -152,7 +152,21 @@
</div>
{% endfor %}
</div>
<div id="purchases"></div>
<div class="row">
<div class="col-md-6 col-md-offset-2">
<div id="purchases"></div>
</div>
<div class="col-md-2">
<div class="well text-center">
<h3>{{ bottles_purchased * 105 }}mg</h3>
<small>Caffeine ingested</small>
</div>
<div class="well text-center">
<h3>{{ bottles_purchased }}</h3>
<small>Bottles purchased</small>
</div>
</div>
</div>
<blockquote class="blockquote-reverse">
<p>Kowalski czuje zapach pieniędzy.</p>
@ -168,7 +182,7 @@ d3.json('/api/1/history.json', function(data) {
title: "Purchases",
data: data,
height: 200,
width: 600,
full_width: true,
target: document.getElementById('purchases'),
x_accessor: 'date',
y_accessor: 'purchases'

View File

@ -31,6 +31,10 @@ def index():
.limit(5) \
.all()
bottles_purchased = Transaction.query \
.filter(Transaction.amount.in_([-500, -600]), Transaction.type == 'purchase') \
.count()
if current_user.is_authenticated:
transactions = current_user.transactions.order_by(Transaction.created.desc()).limit(10)
@ -41,6 +45,7 @@ def index():
transfer_form=TransferForm(),
hallofshame=hallofshame,
hallofaddicts=hallofaddicts,
bottles_purchased=bottles_purchased,
)
@bp.route('/transactions/', defaults={'page': 1})