filter every element on clientside

This commit is contained in:
Florian Bezannier
2021-05-10 20:53:53 +02:00
parent 335c8f79bf
commit c111d87640
11 changed files with 3916 additions and 162 deletions
+6
View File
@@ -38,6 +38,12 @@ class Car:
def is_hybrid(self) -> bool:
return self.fuel_capacity > 0 and self.battery_power > 0
def has_battery(self):
return self.battery_power > 0
def has_fuel(self):
return self.fuel_capacity > 0
def get_status(self):
if self.status is not None:
return self.status
+2 -10
View File
@@ -13,17 +13,9 @@ class Charging:
elec_price: ElecPrice = ElecPrice(None)
@staticmethod
def get_chargings(mini=None, maxi=None) -> List[dict]:
def get_chargings() -> List[dict]:
conn = Database.get_db()
if mini is not None:
if maxi is not None:
res = conn.execute("select * from battery WHERE start_at>=? and start_at<=?", (mini, maxi)).fetchall()
else:
res = conn.execute("select * from battery WHERE start_at>=?", (mini,)).fetchall()
elif maxi is not None:
res = conn.execute("select * from battery WHERE start_at<=?", (maxi,)).fetchall()
else:
res = conn.execute("select * from battery").fetchall()
res = conn.execute("select * from battery ORDER BY start_at").fetchall()
conn.close()
return list(map(dict, res))