mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-22 01:16:14 +00:00
clode clean
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import traceback
|
||||
from statistics import mean
|
||||
from typing import List, Dict
|
||||
|
||||
@@ -233,8 +232,8 @@ class Trips(list):
|
||||
|
||||
def get_info(self):
|
||||
res = []
|
||||
id = 1
|
||||
row_id = 1
|
||||
for trip in self:
|
||||
res.append(trip.get_info(id))
|
||||
id += 1
|
||||
res.append(trip.get_info(row_id))
|
||||
row_id += 1
|
||||
return res
|
||||
|
||||
@@ -156,8 +156,8 @@ class Database:
|
||||
logger.warning("There is %s to fetch from API, it can take some time", nb_null)
|
||||
try:
|
||||
while True:
|
||||
res = conn.execute(f"SELECT DISTINCT latitude,longitude "
|
||||
f"FROM position WHERE altitude IS NULL LIMIT {max_pos_by_req};").fetchall()
|
||||
res = conn.execute("SELECT DISTINCT latitude,longitude "
|
||||
"FROM position WHERE altitude IS NULL LIMIT ?;", max_pos_by_req).fetchall()
|
||||
nb_res = len(res)
|
||||
if nb_res > 0:
|
||||
logger.debug("add altitude for %s positions point", len(nb_null))
|
||||
|
||||
+2
-2
@@ -3,6 +3,7 @@ from datetime import datetime
|
||||
|
||||
from typing import List
|
||||
|
||||
import pytz
|
||||
import dash_bootstrap_components as dbc
|
||||
import dash_table
|
||||
import numpy as np
|
||||
@@ -14,7 +15,6 @@ import plotly.graph_objects as go
|
||||
from pandas import DataFrame
|
||||
from pandas import options as pandas_options
|
||||
import dash_html_components as html
|
||||
import pytz
|
||||
|
||||
from libs.car import Car
|
||||
from libs.elec_price import ElecPrice
|
||||
@@ -256,7 +256,7 @@ def get_battery_curve_fig(row: dict, car: Car):
|
||||
return html.Div(Graph(figure=fig))
|
||||
|
||||
|
||||
def get_altitude_fig(trip:Trip):
|
||||
def get_altitude_fig(trip: Trip):
|
||||
conn = Database.get_db()
|
||||
res = list(map(list, conn.execute("SELECT mileage, altitude FROM position WHERE Timestamp>=? and Timestamp<=?;",
|
||||
(trip.start_at, trip.end_at)).fetchall()))
|
||||
|
||||
+4
-4
@@ -127,7 +127,7 @@ def get_altitude(active_cell, close, is_open): # pylint: disable=unused-argumen
|
||||
if is_open is None:
|
||||
is_open = False
|
||||
if active_cell is not None and active_cell["column_id"] in ["altitude_diff"] and not is_open:
|
||||
return figures.get_altitude_fig(trips[active_cell["row_id"]-1]), True
|
||||
return figures.get_altitude_fig(trips[active_cell["row_id"] - 1]), True
|
||||
return "", False
|
||||
|
||||
|
||||
@@ -356,9 +356,9 @@ def serve_layout():
|
||||
dbc.Tab(label="Map", tab_id="map", children=[maps]),
|
||||
dbc.Tab(label="Control", tab_id="control", children=dbc.Tabs(id="control-tabs",
|
||||
children=__get_control_tabs()))],
|
||||
id="tabs",
|
||||
active_tab="summary",
|
||||
persistence=True),
|
||||
id="tabs",
|
||||
active_tab="summary",
|
||||
persistence=True),
|
||||
html.Div(id=EMPTY_DIV),
|
||||
html.Div(id=EMPTY_DIV + "1")
|
||||
])])
|
||||
|
||||
Reference in New Issue
Block a user