More indexes; parallel daily is ported

Rafael
Rafael M. Martins 7 months ago
parent c251be630b
commit 3907bc8009
  1. 2
      py/import.py
  2. 24
      py/main.py
  3. 4
      web-html/z_FORMATS_NEEDED.js

@ -78,6 +78,8 @@ for hus_name in next(os.walk(BASEDIR))[1]:
con.commit()
cur.execute(f'CREATE INDEX idx_{card}_Year ON {table_name} (Year)')
cur.execute(f'CREATE INDEX idx_{card}_Month ON {table_name} (Month)')
cur.execute(f'CREATE INDEX idx_{card}_Day ON {table_name} (Day)')
cur.execute(f'CREATE INDEX idx_{card}_Hour ON {table_name} (Hour)')
con.commit()

@ -90,21 +90,28 @@ def parallel_daily():
# Get the right sensors for the family
table_name, col_names = get_table_cols(hus, fam, typ)
sql_col_names = ','.join(f'"{x}"' for x in col_names)
sql_col_names = ','.join(f'"{x}"' for x in col_names)
# Split date
yea, mon, day = day.split('-')
query = (f'SELECT {sql_col_names} FROM {table_name}'
f' WHERE Year=? AND Month=? AND Day=?'
f' GROUP BY Hour;')
conn = sqlite3.connect(DB_NAMES[hus])
cur = conn.execute(f'SELECT {sql_col_names} FROM "{table_name}" WHERE "{date_col}"=?;', [day])
cur = conn.execute(query, [yea, mon, day])
res_all = cur.fetchall()
cur.close()
sample = [["pos1", *[x*10+10 for x in range(len(col_names)-2)]]]
sample = [["pos1", *[x*10+10 for x in range(len(col_names)-6)]]]
myxs = {}
for k, g in itertools.groupby(res_all, lambda x: x[1][:2]):
data_point = next(g)
point_id = f'{data_point[1]}'
for data_point in res_all:
point_id = ':'.join(data_point[3:6])
myxs[point_id] = 'pos1'
data_point = [point_id, *data_point[2:]]
data_point = [point_id, *data_point[6:]]
sample.append(data_point)
return dict(sample=sample, myxs=myxs)
@ -122,10 +129,11 @@ def parallel_weekly():
#if not wee or not yea:
# return 'ERROR: You need to at least specify the parameters "week" and "year".'
# Find monday from the given week
monday = date.fromisocalendar(yea, wee, 1)
weekday_names = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
weekdays = {str(monday + timedelta(days=x)):weekday_names[x] for x in range(7)}
#print(weekdays)
print(weekdays)
# Get the right sensors for the family
table_name, col_names = get_table_cols(hus, fam, typ)

@ -61,7 +61,7 @@ myxs = {
// allow for chosing a different date/time
// monthly: date: choose days 1/8/15/22/29; time; 12:00;
// allow for chosing different date/time
// daily: time: 0-1-2-3-...-24;
// daily: time: 0-1-2-3-...-23;
// allow for chosing different date/time
//
// Is it possible to allow to supress a line then (hide it)?
@ -89,7 +89,7 @@ var Temp_MP1_1_Pos4 = [
// - yearly - 365 days; 12 rows with 28-31 days; at 12:00;
// - monthly - 28 days; 4 rows with 7 days; at 12:00;
// - can this be arranged like in calendar view?
// - weekly - 7 days; 4 rows with 24 hours; at ##:00;
// - weekly - 7 days; one per day at ##:00;
//
// Scale: is it possible here to chose if an actual time is shown or to have the max/min value within a day for the yearly/monthly versions?
//

Loading…
Cancel
Save