Compare commits

...

2 Commits

Author SHA1 Message Date
ahosking
da166e5169 Check the value of winter on the last record
This will ensure that the UX is consistent after the first change to/from
Winter is made
2022-11-03 00:06:32 -04:00
ahosking
526e6d3439 Extend Data search to 90 days
Add Winter value to the data selected and passed to index
2022-11-03 00:05:56 -04:00
2 changed files with 17 additions and 5 deletions

View File

@ -27,7 +27,7 @@ def success():
def main_page(): def main_page():
query_api = client.query_api() query_api = client.query_api()
query = 'from(bucket: "gas")\ query = 'from(bucket: "gas")\
|> range(start: -30d)\ |> range(start: -90d)\
|> filter(fn: (r) => r["_measurement"] == "2016_odyssey")\ |> filter(fn: (r) => r["_measurement"] == "2016_odyssey")\
|> filter(fn: (r) => r["_field"] == "odometer")\ |> filter(fn: (r) => r["_field"] == "odometer")\
|> sort(columns: ["_value"], desc: false)\ |> sort(columns: ["_value"], desc: false)\
@ -50,6 +50,10 @@ def main_page():
temp['fuelcost'] = record['fuelcost'] temp['fuelcost'] = record['fuelcost']
except KeyError: except KeyError:
pass pass
try:
temp['winter'] = record['winter']
except KeyError:
pass
results.append(temp) results.append(temp)
# .append((record.get_time(), record.get_field(), record.get_value())) # .append((record.get_time(), record.get_field(), record.get_value()))
newlist = sorted(results, key=itemgetter('time'), reverse=True) newlist = sorted(results, key=itemgetter('time'), reverse=True)

View File

@ -47,9 +47,17 @@
<div class="row"> <div class="row">
<div class="col-xs-4"> <div class="col-xs-4">
<label for="winter">Winter Tires:</label> <label for="winter">Winter Tires:</label>
<select name="winter" class="form-control" default="false"> <select name="winter" class="form-control">
{% if data %}
{% if data[0]['winter'] == "True" %}
<option value="TRUE" selected>True</option>
<option value="FALSE">False</option>
{% else %}
<option value="TRUE">True</option> <option value="TRUE">True</option>
<option value="FALSE" selected>False</option> <option value="FALSE" selected>False</option>
{% endif %}
{% endif %}
</select> </select>
</div> </div>
</div><br> </div><br>