summaryrefslogtreecommitdiffstats
path: root/bitvend
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-06-02 14:59:02 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2017-06-02 15:11:56 +0200
commit55dab93eb872ce29c872b379bf5819c9cc6d9a0a (patch)
tree24e6733a41d1c77955c3f0cab2d38d62757eec2c /bitvend
parent4e8e085587c5436b823ee57ba6f333b4aa8c7b5b (diff)
downloadbitvend-55dab93eb872ce29c872b379bf5819c9cc6d9a0a.tar.gz
bitvend-55dab93eb872ce29c872b379bf5819c9cc6d9a0a.tar.bz2
bitvend-55dab93eb872ce29c872b379bf5819c9cc6d9a0a.tar.xz
bitvend-55dab93eb872ce29c872b379bf5819c9cc6d9a0a.zip
Better stats display
Diffstat (limited to 'bitvend')
-rw-r--r--bitvend/templates/index.html18
-rw-r--r--bitvend/views.py5
2 files changed, 21 insertions, 2 deletions
diff --git a/bitvend/templates/index.html b/bitvend/templates/index.html
index 6b97250..1960b67 100644
--- a/bitvend/templates/index.html
+++ b/bitvend/templates/index.html
@@ -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'
diff --git a/bitvend/views.py b/bitvend/views.py
index d1bb909..d9da2dd 100644
--- a/bitvend/views.py
+++ b/bitvend/views.py
@@ -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})