Merge pull request #487 from Philippehaz/Issue-486

Fix #486 and maybe #437
This commit is contained in:
Florian BEZANNIER
2023-08-21 20:50:47 +02:00
committed by GitHub
2 changed files with 3 additions and 2 deletions
@@ -21,7 +21,7 @@ class BatteryChargeCurve:
conn = Database.get_db()
conn.close()
battery_curves = []
if len(battery_curves_dto) > 0 and battery_curves_dto[-1].level > 0:
if len(battery_curves_dto) > 0 and battery_curves_dto[-1].level > 0 and battery_curves_dto[-1].autonomy > 0:
battery_capacity = battery_curves_dto[-1].level * car.battery_power / 100
km_by_kw = 0.8 * battery_curves_dto[-1].autonomy / battery_capacity
start = 0
+2 -1
View File
@@ -182,7 +182,8 @@ class Database:
battery_curves = []
res = conn.execute("""SELECT date, level, rate, autonomy
FROM battery_curve
WHERE start_at=? and date<=? and VIN=?;""",
WHERE start_at=? and date<=? and VIN=?
ORDER BY date asc;""",
(start_at, stop_at, vin)).fetchall()
for row in res:
battery_curves.append(BatteryCurveDto(**dict_key_to_lower_case(**row)))