Express furnace run numbers on history page.
This commit is contained in:
@ -69,7 +69,7 @@ def lab_temp():
|
|||||||
|
|
||||||
@app.route("/history", methods=['GET']) #Add date limits in the URL #Arguments: from=2015-03-04&to=2015-03-05
|
@app.route("/history", methods=['GET']) #Add date limits in the URL #Arguments: from=2015-03-04&to=2015-03-05
|
||||||
def history():
|
def history():
|
||||||
temperatures, humidities, timezone, from_date_str, to_date_str = get_records()
|
temperatures, humidities, timezone, from_date_str, to_date_str, range_hours = get_records()
|
||||||
|
|
||||||
# Create new record tables so that datetimes are adjusted back to the user browser's time zone.
|
# Create new record tables so that datetimes are adjusted back to the user browser's time zone.
|
||||||
time_series_adjusted_temperatures = []
|
time_series_adjusted_temperatures = []
|
||||||
@ -127,10 +127,11 @@ def history():
|
|||||||
# Calculate minutes for each streak
|
# Calculate minutes for each streak
|
||||||
streak_minutes = streak_lengths(time_series_temperature_values)*timestep_minutes
|
streak_minutes = streak_lengths(time_series_temperature_values)*timestep_minutes
|
||||||
|
|
||||||
|
# Send output to page
|
||||||
return render_template("history.html", timezone = timezone,
|
return render_template("history.html", timezone = timezone,
|
||||||
graphJSON = graphJSON,
|
graphJSON = graphJSON,
|
||||||
total_minutes = sum(streak_minutes),
|
total_minutes = sum(streak_minutes),
|
||||||
|
range_hours = range_hours
|
||||||
)
|
)
|
||||||
# Calculate streak lengths (https://stackoverflow.com/a/20614650/2152245)
|
# Calculate streak lengths (https://stackoverflow.com/a/20614650/2152245)
|
||||||
def streak_lengths(temps):
|
def streak_lengths(temps):
|
||||||
@ -195,7 +196,7 @@ def get_records():
|
|||||||
humidities = curs.fetchall()
|
humidities = curs.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
return [temperatures, humidities, timezone, from_date_str, to_date_str]
|
return [temperatures, humidities, timezone, from_date_str, to_date_str, range_h_int]
|
||||||
|
|
||||||
def validate_date(d):
|
def validate_date(d):
|
||||||
try:
|
try:
|
||||||
|
@ -34,32 +34,32 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form id="datetime_range" action="/history" method="GET">
|
<form id="datetime_range" action="/history" method="GET">
|
||||||
<!-- <div class="row"> -->
|
<!-- <div class="row"> -->
|
||||||
<div class="three columns">
|
<div class="three columns">
|
||||||
<label for="from">From date</label>
|
<label for="from">From date</label>
|
||||||
<input class="u-full-width" id="datetimepicker1" type="text" value="{{from_date}}" name="from">
|
<input class="u-full-width" id="datetimepicker1" type="text" value="{{from_date}}" name="from">
|
||||||
</div>
|
</div>
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<!-- <div class="row"> -->
|
<!-- <div class="row"> -->
|
||||||
<div class="three columns">
|
<div class="three columns">
|
||||||
<label for="to">To date</label>
|
<label for="to">To date</label>
|
||||||
<input class="u-full-width" id="datetimepicker2" type="text" value="{{to_date}}" name="to">
|
<input class="u-full-width" id="datetimepicker2" type="text" value="{{to_date}}" name="to">
|
||||||
</div>
|
</div>
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<!-- <div class="row"> -->
|
<!-- <div class="row"> -->
|
||||||
<div class="two columns">
|
<div class="two columns">
|
||||||
<input type="hidden" class="timezone" name="timezone" />
|
<input type="hidden" class="timezone" name="timezone" />
|
||||||
<input class="button-primary" type="submit" value="Submit" style="position:relative; top: 28px" id="submit_button" />
|
<input class="button-primary" type="submit" value="Submit" style="position:relative; top: 28px" id="submit_button" />
|
||||||
</div>
|
</div>
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="eleven columns">
|
<div class="eleven columns">
|
||||||
<div class="one column">
|
<div class="one column">
|
||||||
<a href="/">Live</a>
|
<a href="/">Live</a>
|
||||||
</div>
|
</div>
|
||||||
<form id="range_select" action = "/history" method="GET">
|
<form id="range_select" action = "/history" method="GET">
|
||||||
<input type="hidden" class="timezone" name="timezone" />
|
<input type="hidden" class="timezone" name="timezone" />
|
||||||
<div class="one column">
|
<div class="one column">
|
||||||
@ -77,9 +77,10 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='row' id='plotly-plot'></div>
|
|
||||||
|
|
||||||
{{ total_minutes }}
|
Furnace averaging {{ "%.2f" % (total_minutes/range_hours) }} minutes/hr ({{ total_minutes }} minutes total).
|
||||||
|
|
||||||
|
<div class='row' id='plotly-plot'></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user