Show current prices on webapp (table + graph)
This commit is contained in:
@@ -14,6 +14,11 @@
|
|||||||
<th>1000-1499 L</th>
|
<th>1000-1499 L</th>
|
||||||
<th>500-999 L</th>
|
<th>500-999 L</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="current">
|
||||||
|
<td colspan="2">Actuellement</td>
|
||||||
|
<td>{{current_1000}}</td>
|
||||||
|
<td>{{current_500}}</td>
|
||||||
|
</tr>
|
||||||
% for x in results:
|
% for x in results:
|
||||||
<tr class="{{day_classes[x.date.weekday()]}}">
|
<tr class="{{day_classes[x.date.weekday()]}}">
|
||||||
<td>{{x.date.strftime('%A')}}</td>
|
<td>{{x.date.strftime('%A')}}</td>
|
||||||
@@ -32,13 +37,44 @@
|
|||||||
y: {{ [d.price for d in results] }},
|
y: {{ [d.price for d in results] }},
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
name: '1000-1499 L',
|
name: '1000-1499 L',
|
||||||
|
marker: {
|
||||||
|
color: '#1f77b4',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x: {{ [str(d.date) for d in results if d.price500 is not None] }},
|
x: {{ [str(d.date) for d in results if d.price500 is not None] }},
|
||||||
y: {{ [d.price500 for d in results if d.price500 is not None] }},
|
y: {{ [d.price500 for d in results if d.price500 is not None] }},
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
name: '500-999 L',
|
name: '500-999 L',
|
||||||
}];
|
marker: {
|
||||||
|
color: '#ff7f0e',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: [new Date().toJSON().slice(0, 10)],
|
||||||
|
y: [{{ current_1000 }}],
|
||||||
|
type: 'scatter',
|
||||||
|
name: 'today',
|
||||||
|
showlegend: false,
|
||||||
|
mode: 'markers',
|
||||||
|
marker: {
|
||||||
|
symbol: 'cross',
|
||||||
|
color: '#1f77b4',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: [new Date().toJSON().slice(0, 10)],
|
||||||
|
y: [{{ current_500 }}],
|
||||||
|
type: 'scatter',
|
||||||
|
name: 'today',
|
||||||
|
showlegend: false,
|
||||||
|
mode: 'markers',
|
||||||
|
marker: {
|
||||||
|
symbol: 'cross',
|
||||||
|
color: '#ff7f0e',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
var plotLayout = {
|
var plotLayout = {
|
||||||
margin: { t: 0 }
|
margin: { t: 0 }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import os
|
|||||||
from bottle import hook, request, route, run, static_file, view
|
from bottle import hook, request, route, run, static_file, view
|
||||||
|
|
||||||
import models
|
import models
|
||||||
|
from fioul import get_today_prices_from_internet
|
||||||
from models import Price
|
from models import Price
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
@@ -14,6 +15,7 @@ from models import Price
|
|||||||
@view("search_results", template_settings={"noescape": True})
|
@view("search_results", template_settings={"noescape": True})
|
||||||
def results_page():
|
def results_page():
|
||||||
results = Price.select().order_by(Price.date.desc())
|
results = Price.select().order_by(Price.date.desc())
|
||||||
|
current_500, current_1000 = get_today_prices_from_internet()
|
||||||
day_classes = {
|
day_classes = {
|
||||||
0: "monday",
|
0: "monday",
|
||||||
1: "tuesday",
|
1: "tuesday",
|
||||||
@@ -23,7 +25,12 @@ def results_page():
|
|||||||
5: "saturday",
|
5: "saturday",
|
||||||
6: "sunday",
|
6: "sunday",
|
||||||
}
|
}
|
||||||
return dict(results=results, day_classes=day_classes)
|
return dict(
|
||||||
|
results=results,
|
||||||
|
day_classes=day_classes,
|
||||||
|
current_500=current_500,
|
||||||
|
current_1000=current_1000,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@route("/static/<filename>")
|
@route("/static/<filename>")
|
||||||
|
|||||||
Reference in New Issue
Block a user