Add Winter parameter for Repeat entries

This commit is contained in:
Alexander Hosking 2022-12-29 23:25:32 -05:00
parent 277930acde
commit 7531c9cc7c
2 changed files with 7 additions and 4 deletions

View File

@ -126,8 +126,8 @@ def add_time():
return redirect(url_for('main_page'))
@app.route('/repeat_last_odometer/<odometer>')
def repeat_last_odometer(odometer):
@app.route('/repeat_last_odometer/<odometer>/<winter>')
def repeat_last_odometer(odometer, winter=False):
'''Retrieve the passed in odometer value and submit as a new entry'''
date = strftime("%Y-%m-%d")
time = strftime("%H:%M:%S")
@ -136,7 +136,7 @@ def repeat_last_odometer(odometer):
write_api = client.write_api(write_options=SYNCHRONOUS)
point = influxdb_client.Point("2016_odyssey").time(
timestamp).field("odometer", float(odometer))
timestamp).tag("winter", winter).field("odometer", float(odometer))
write_api.write(bucket="gas", org=config['DB_ORG'], record=point)
return redirect(url_for('main_page'))

View File

@ -57,13 +57,16 @@
<option value="TRUE">True</option>
<option value="FALSE" selected>False</option>
{% endif %}
{% else %}
<option value="TRUE">True</option>
<option value="FALSE" selected>False</option>
{% endif %}
</select>
</div>
</div><br>
<input type="submit" value="Go">
{% if data %}
<a href="{{ url_for('repeat_last_odometer', odometer=data[0]['odometer'] ) }}">Repeat</a>
<a href="{{ url_for('repeat_last_odometer', odometer=data[0]['odometer'], winter=data[0]['winter'] ) }}">Repeat</a>
{% endif %}
</div>
</form>