|
|
|
@ -216,34 +216,37 @@ def parallel_yearly(): |
|
|
|
|
hus = request.args.get('hus', 'Charlie') |
|
|
|
|
fam = request.args.get('family', 'MP1_1') |
|
|
|
|
typ = request.args.get('type', 'celsius') |
|
|
|
|
yea = int(request.args.get('year', '2023')) |
|
|
|
|
yea = request.args.get('year', '2023') |
|
|
|
|
|
|
|
|
|
#if not wee or not yea: |
|
|
|
|
# return 'ERROR: You need to at least specify the parameters "week" and "year".' |
|
|
|
|
|
|
|
|
|
# first days of each of the 12 months |
|
|
|
|
days = [str(date(yea, x, 1)) for x in range(1, 13)] |
|
|
|
|
|
|
|
|
|
conn = sqlite3.connect(DB_NAMES[hus]) |
|
|
|
|
#days = [str(date(yea, x, 1)) for x in range(1, 13)] |
|
|
|
|
|
|
|
|
|
# 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) |
|
|
|
|
|
|
|
|
|
cur = conn.execute(f'SELECT {sql_col_names} FROM "{table_name}" WHERE "{date_col}" IN (?,?,?,?,?,?,?,?,?,?,?,?);', days) |
|
|
|
|
|
|
|
|
|
conn = sqlite3.connect(DB_NAMES[hus]) |
|
|
|
|
#cur = conn.execute(f'SELECT {sql_col_names} FROM "{table_name}" WHERE "{date_col}" IN (?,?,?,?,?,?,?,?,?,?,?,?);', days) |
|
|
|
|
cur = conn.execute(f'SELECT {sql_col_names} FROM {table_name}' |
|
|
|
|
' WHERE Year=? GROUP BY Month;', [yea]) |
|
|
|
|
res_all = cur.fetchall() |
|
|
|
|
|
|
|
|
|
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 = {} |
|
|
|
|
month_names = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] |
|
|
|
|
# group by day; take first of each group |
|
|
|
|
for k, g in itertools.groupby(res_all, lambda x: x[0]): |
|
|
|
|
data_point = next(g) |
|
|
|
|
month_num = int(data_point[0][5:7])-1 |
|
|
|
|
#for k, g in itertools.groupby(res_all, lambda x: x[0]): |
|
|
|
|
for data_point in res_all: |
|
|
|
|
#data_point = next(g) |
|
|
|
|
month_num = int(data_point[1])-1 |
|
|
|
|
point_id = f'{month_names[month_num]}' |
|
|
|
|
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) |
|
|
|
|