|
|
|
@ -109,7 +109,7 @@ def parallel_daily(): |
|
|
|
|
myxs = {} |
|
|
|
|
|
|
|
|
|
for data_point in res_all: |
|
|
|
|
point_id = ':'.join(data_point[3:6]) |
|
|
|
|
point_id = ':'.join(format(y, '02d') for y in data_point[3:6]) |
|
|
|
|
myxs[point_id] = 'pos1' |
|
|
|
|
data_point = [point_id, *data_point[6:]] |
|
|
|
|
sample.append(data_point) |
|
|
|
@ -179,9 +179,12 @@ def parallel_monthly(): |
|
|
|
|
typ = request.args.get('type', 'celsius') |
|
|
|
|
mon = int(request.args.get('month', '1')) |
|
|
|
|
yea = int(request.args.get('year', '2023')) |
|
|
|
|
wda = int(request.args.get('weekday', 1)) |
|
|
|
|
wda = int(request.args.get('weekday', 0)) |
|
|
|
|
hou = int(request.args.get('hour', '0')) |
|
|
|
|
|
|
|
|
|
if wda < 0 or wda > 6: |
|
|
|
|
wda = 0 |
|
|
|
|
|
|
|
|
|
# Make sure format is right |
|
|
|
|
hou = f'{hou:02d}' |
|
|
|
|
|
|
|
|
@ -189,7 +192,10 @@ def parallel_monthly(): |
|
|
|
|
# return 'ERROR: You need to at least specify the parameters "week" and "year".' |
|
|
|
|
|
|
|
|
|
# first days of the 4 weeks |
|
|
|
|
first = date(yea, mon, wda) |
|
|
|
|
first = date(yea, mon, 1) |
|
|
|
|
while first.weekday() != wda: |
|
|
|
|
first = first + timedelta(days=1) |
|
|
|
|
|
|
|
|
|
days = [str(first + timedelta(days=7*x)) for x in range(4)] |
|
|
|
|
|
|
|
|
|
# Get the right sensors for the family |
|
|
|
@ -215,7 +221,7 @@ def parallel_monthly(): |
|
|
|
|
myxs = {} |
|
|
|
|
# group by day; take first of each group |
|
|
|
|
for data_point in res_all: |
|
|
|
|
point_id = '-'.join(data_point[:3]) |
|
|
|
|
point_id = '-'.join(format(y, '02d') for y in data_point[:3]) |
|
|
|
|
myxs[point_id] = 'pos1' |
|
|
|
|
data_point = [point_id, *data_point[6:]] |
|
|
|
|
sample.append(data_point) |
|
|
|
@ -290,8 +296,8 @@ def grid_yearly(): |
|
|
|
|
res_all = cur.fetchall() |
|
|
|
|
|
|
|
|
|
out = [] |
|
|
|
|
out.append(['-'.join(x[:3]) for x in res_all]) |
|
|
|
|
out.append([':'.join(x[3:6]) for x in res_all]) |
|
|
|
|
out.append(['-'.join(format(y, '02d') for y in x[:3]) for x in res_all]) |
|
|
|
|
out.append([':'.join(format(y, '02d') for y in x[3:6]) for x in res_all]) |
|
|
|
|
out.append([x[6] for x in res_all]) |
|
|
|
|
|
|
|
|
|
return out |
|
|
|
@ -325,8 +331,8 @@ def grid_monthly(): |
|
|
|
|
res_all = cur.fetchall() |
|
|
|
|
|
|
|
|
|
out = [] |
|
|
|
|
out.append(['-'.join(x[:3]) for x in res_all]) |
|
|
|
|
out.append([':'.join(x[3:6]) for x in res_all]) |
|
|
|
|
out.append(['-'.join(format(y, '02d') for y in x[:3]) for x in res_all]) |
|
|
|
|
out.append([':'.join(format(y, '02d') for y in x[3:6]) for x in res_all]) |
|
|
|
|
out.append([x[6] for x in res_all]) |
|
|
|
|
|
|
|
|
|
return out |
|
|
|
@ -370,8 +376,8 @@ def grid_weekly(): |
|
|
|
|
res_all = cur.fetchall() |
|
|
|
|
|
|
|
|
|
out = [] |
|
|
|
|
out.append(['-'.join(x[:3]) for x in res_all]) |
|
|
|
|
out.append([':'.join(x[3:6]) for x in res_all]) |
|
|
|
|
out.append(['-'.join(format(y, '02d') for y in x[:3]) for x in res_all]) |
|
|
|
|
out.append([':'.join(format(y, '02d') for y in x[3:6]) for x in res_all]) |
|
|
|
|
out.append([x[6] for x in res_all]) |
|
|
|
|
|
|
|
|
|
return out |
|
|
|
@ -417,8 +423,8 @@ def horizon_yearly(): |
|
|
|
|
for i, sensor_name in enumerate(out['sensor_names']): |
|
|
|
|
sensor_data_sorted = sorted(aux_data[sensor_name]) |
|
|
|
|
if i == 0: |
|
|
|
|
out['days'] = ['-'.join(x[:3]) for x in sensor_data_sorted] |
|
|
|
|
out['times'] = [':'.join(x[3:6]) for x in sensor_data_sorted] |
|
|
|
|
out['days'] = ['-'.join(format(y, '02d') for y in x[:3]) for x in sensor_data_sorted] |
|
|
|
|
out['times'] = [':'.join(format(y, '02d') for y in x[3:6]) for x in sensor_data_sorted] |
|
|
|
|
out[sensor_name] = [x[6] for x in sensor_data_sorted] |
|
|
|
|
|
|
|
|
|
return out |
|
|
|
@ -459,8 +465,8 @@ def horizon_monthly(): |
|
|
|
|
# Important: this only works assuming that res_all is correctly sorted |
|
|
|
|
|
|
|
|
|
for row in res_all: |
|
|
|
|
out['days'].append('-'.join(row[:3])) |
|
|
|
|
out['times'].append(':'.join(row[3:6])) |
|
|
|
|
out['days'].append('-'.join(format(y, '02d') for y in row[:3])) |
|
|
|
|
out['times'].append(':'.join(format(y, '02d') for y in row[3:6])) |
|
|
|
|
for i in range(6, len(row)): |
|
|
|
|
out[out['sensor_names'][i-6]].append(row[i]) |
|
|
|
|
|
|
|
|
@ -505,8 +511,8 @@ def horizon_weekly(): |
|
|
|
|
# Important: this only works assuming that res_all is correctly sorted |
|
|
|
|
|
|
|
|
|
for row in res_all: |
|
|
|
|
out['days'].append('-'.join(row[:3])) |
|
|
|
|
out['times'].append(':'.join(row[3:6])) |
|
|
|
|
out['days'].append('-'.join(format(y, '02d') for y in row[:3])) |
|
|
|
|
out['times'].append(':'.join(format(y, '02d') for y in row[3:6])) |
|
|
|
|
for i in range(6, len(row)): |
|
|
|
|
out[out['sensor_names'][i-6]].append(row[i]) |
|
|
|
|
|
|
|
|
@ -546,8 +552,8 @@ def horizon_daily(): |
|
|
|
|
# Important: this only works assuming that res_all is correctly sorted |
|
|
|
|
|
|
|
|
|
for row in res_all: |
|
|
|
|
out['days'].append('-'.join(row[:3])) |
|
|
|
|
out['times'].append(':'.join(row[3:6])) |
|
|
|
|
out['days'].append('-'.join(format(y, '02d') for y in row[:3])) |
|
|
|
|
out['times'].append(':'.join(format(y, '02d') for y in row[3:6])) |
|
|
|
|
for i in range(6, len(row)): |
|
|
|
|
out[out['sensor_names'][i-6]].append(row[i]) |
|
|
|
|
|
|
|
|
|