|
|
|
@ -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) |
|
|
|
|