Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions psa_car_controller/psacc/model/trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,20 @@ def to_geojson(self):
"average consumption fuel": self.consumption_fuel_km})

def get_info(self):

res = {"consumption_km": self.consumption_km, "start_at": self.start_at,
"consumption_by_temp": self.get_temperature(), "positions": self.get_positions(),
"duration": self.duration * 60, "speed_average": self.speed_average, "distance": self.distance,
"mileage": self.mileage, "altitude_diff": self.altitude_diff, "id": self.id,
"consumption": self.consumption
}
res = {
"consumption_km": self.consumption_km,
"start_at": self.start_at,
"end_at": self.end_at,
"consumption_by_temp": self.get_temperature(),
"positions": self.get_positions(),
"duration": self.duration * 60,
"speed_average": self.speed_average,
"distance": self.distance,
"mileage": self.mileage,
"altitude_diff": self.altitude_diff,
"id": self.id,
"consumption": self.consumption,
}
if self.car.has_battery():
res["consumption_km"] = self.consumption_km

Expand Down
1 change: 1 addition & 0 deletions psa_car_controller/web/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def get_figures(car: Car):
},
columns=[{'id': 'id', 'name': '#', 'type': 'numeric'},
{'id': 'start_at_str', 'name': 'start at', 'type': 'datetime'},
{'id': 'end_at_str', 'name': 'end at', 'type': 'datetime'},
{'id': 'duration', 'name': 'duration', 'type': 'numeric',
'format': deepcopy(nb_format).symbol_suffix(" min").precision(0)},
{'id': 'speed_average', 'name': 'avg. speed', 'type': 'numeric',
Expand Down
3 changes: 3 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def test_record_position_charging(self):
res = trip.get_info()
assert compare_dict(res, {'consumption_km': 24.21052631578947,
'start_at': date0,
'end_at': date2,
'consumption_by_temp': None,
'positions': {'lat': [latitude], 'long': [longitude]},
'duration': 40.0, 'speed_average': 28.5, 'distance': 19.0, 'mileage': 30.0,
Expand Down Expand Up @@ -266,6 +267,7 @@ def test_fuel_car(self):
res = trips[car.vin].get_trips_as_dict()
assert compare_dict(res, [{'consumption_km': 6.947368421052632,
'start_at': date0,
'end_at': date2,
'consumption_by_temp': None,
'positions': {'lat': [latitude],
'long': [longitude]},
Expand Down Expand Up @@ -294,6 +296,7 @@ def test_none_mileage(self):
res = trips[car.vin].get_trips_as_dict()
assert compare_dict(res, [{'consumption_km': 6.947368421052632,
'start_at': start,
'end_at': end,
'consumption_by_temp': None,
'positions': {'lat': [latitude],
'long': [longitude]},
Expand Down