making graphs n shit
This commit is contained in:
parent
200aaa066c
commit
ff30728863
|
@ -56,6 +56,17 @@ def mod_queue():
|
|||
def about():
|
||||
return render_template("about.html")
|
||||
|
||||
@app.route("/stats")
|
||||
def stats():
|
||||
wow_txes = list()
|
||||
posts = Post.select()
|
||||
wallet = wownero.Wallet()
|
||||
for post in posts:
|
||||
txes = wallet.transfers(post.account_index)
|
||||
if 'in' in txes:
|
||||
wow_txes.append(txes['in'])
|
||||
return render_template("stats.html", wow_txes=json.dumps(wow_txes))
|
||||
|
||||
@app.errorhandler(404)
|
||||
def not_found(error):
|
||||
flash("nothing there, brah")
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -21,6 +21,9 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('about') }}">About</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('stats') }}">Stats</a>
|
||||
</li>
|
||||
{% if session.auth == None %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('auth.login') }}">Login</a>
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="container" style="text-align:center;">
|
||||
|
||||
<h3>Stats</h3>
|
||||
|
||||
<div style="width: 100%; text-align: center;">
|
||||
<div class="charts">
|
||||
<canvas id="wow_wallet"></canvas>
|
||||
<canvas id="wow_earnings"></canvas>
|
||||
<canvas id="swap_stats"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/Chart.bundle.min.js"></script>
|
||||
<script>
|
||||
var monero = '#f96b0e';
|
||||
var set_title = function(t){
|
||||
return {
|
||||
display: true,
|
||||
text: t,
|
||||
fontColor: 'white',
|
||||
}
|
||||
}
|
||||
|
||||
{% for i in wow_txes %}
|
||||
// console.log("{{ i['in'] }}")
|
||||
{% endfor %}
|
||||
|
||||
{#
|
||||
var ctx = document.getElementById('wow_wallet').getContext('2d');
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: [0, {% for i in wow_txes %}'{{ wow_txes[i].timestamp }}',{% endfor %}],
|
||||
datasets: [{
|
||||
label: 'Balance',
|
||||
backgroundColor: wownero,
|
||||
borderColor: wownero,
|
||||
data: [
|
||||
0, {% for i in wow_txes %}{{ wow_txes[i].total }},{% endfor %}
|
||||
],
|
||||
fill: false,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
title: set_title('Wownero Wallet Balance')
|
||||
}
|
||||
});
|
||||
|
||||
var ctx = document.getElementById('wow_earnings').getContext('2d');
|
||||
new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: ['WOW', 'USD'],
|
||||
datasets: [{
|
||||
label: 'Wownero Earnings',
|
||||
backgroundColor: wownero,
|
||||
borderColor: wownero,
|
||||
data: [
|
||||
{{ earnings['wow'] | from_atomic_wow }}, {{ earnings['wow_as_ausd'] | from_atomic_usd }}
|
||||
],
|
||||
fill: false,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
title: set_title('Wownero Earnings')
|
||||
}
|
||||
});
|
||||
#}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue