Compare commits

...

6 Commits

Author SHA1 Message Date
ahosking
277930acde Add Fuel costs when they exist
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-04 15:17:16 -04:00
ahosking
4aab99bcbc Remove the test phase for now
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-03 00:19:01 -04:00
ahosking
58242e82a6 Add Drone file to start CI/CD
Some checks failed
continuous-integration/drone/push Build is failing
2022-11-03 00:14:55 -04:00
ahosking
3ec11e3051 Add missing requirements 2022-11-03 00:09:17 -04:00
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
4 changed files with 66 additions and 9 deletions

32
.drone.yml Normal file
View File

@ -0,0 +1,32 @@
kind: pipeline
type: docker
name: build
steps:
- name: build
image: python:3-buster
commands:
- export PYTHONPATH=.
- export FLASK_APP=period
- apt-get update -qy
- apt-get install -y python3-dev python3-pip
- pip3 install --upgrade pip
- pip3 install --upgrade setuptools
- pip3 install Flask gunicorn pytest pytest-cov
- pip3 install pendulum
# ---
# kind: pipeline
# type: docker
# name: test
# steps:
# - name: test
# image: python:3-buster
# commands:
# - export PYTHONPATH=.
# - export FLASK_APP=period
# - apt-get update -qy
# - apt-get install -y python3-dev python3-pip
# - pip3 install --upgrade pip
# - pip3 install --upgrade setuptools
# - pip3 install Flask gunicorn pytest pytest-cov
# - pip3 install pendulum
# - pytest tests --cov --cov-report term --cov-report html --junitxml=report.xml

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

@ -1,14 +1,23 @@
autopep8==1.7.0
certifi==2022.6.15 certifi==2022.6.15
click==6.6 click==8.1.3
Flask==2.2.2
importlib-metadata==5.0.0
influxdb-client==1.30.0 influxdb-client==1.30.0
itsdangerous==0.24 itsdangerous==2.1.2
MarkupSafe==0.23 Jinja2==3.1.2
MarkupSafe==2.1.1
pendulum==2.1.2 pendulum==2.1.2
pycodestyle==2.9.1
python-dateutil==2.8.2
python-dotenv==0.21.0
pytz==2016.10 pytz==2016.10
pytzdata==2020.1 pytzdata==2020.1
requests==2.12.4 requests==2.12.4
Rx==3.2.0 Rx==3.2.0
six==1.10.0 six==1.10.0
toml==0.10.2
urllib3==1.26.9 urllib3==1.26.9
Werkzeug==0.11.11 Werkzeug==2.2.2
WTForms==2.1 WTForms==2.1
zipp==3.10.0

View File

@ -47,10 +47,18 @@
<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">
<option value="TRUE">True</option> {% if data %}
<option value="FALSE" selected>False</option> {% if data[0]['winter'] == "True" %}
</select> <option value="TRUE" selected>True</option>
<option value="FALSE">False</option>
{% else %}
<option value="TRUE">True</option>
<option value="FALSE" selected>False</option>
{% endif %}
{% endif %}
</select>
</div> </div>
</div><br> </div><br>
<input type="submit" value="Go"> <input type="submit" value="Go">
@ -69,6 +77,7 @@ Last Mileage
<th scope="col">Oil</th> <th scope="col">Oil</th>
<th scope="col">Litres</th> <th scope="col">Litres</th>
<th scope="col">$/Litre</th> <th scope="col">$/Litre</th>
<th scope="col">$ Total</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -79,6 +88,9 @@ Last Mileage
<td>{{ point['oilhealth'] }}</td> <td>{{ point['oilhealth'] }}</td>
<td>{{ point['fuel'] }}</td> <td>{{ point['fuel'] }}</td>
<td>{{ point['fuelcost'] }}</td> <td>{{ point['fuelcost'] }}</td>
{% if point['fuel'] %}
<td>{{ '%0.2f' % ((point['fuel'] | float) * (point['fuelcost'] | float)) }}</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>