|
|
|
@ -141,7 +141,7 @@ def parallel_weekly(): |
|
|
|
|
|
|
|
|
|
# Complex query to get each day of the week |
|
|
|
|
query = f'SELECT {sql_col_names} FROM {table_name} WHERE' |
|
|
|
|
query += 'OR'.join('(Year=? AND Month=? AND Day=?)' for _ in range(len(weekdays))) |
|
|
|
|
query += 'OR'.join(['(Year=? AND Month=? AND Day=?)'] * len(weekdays)) |
|
|
|
|
query += ' GROUP BY Day;' |
|
|
|
|
|
|
|
|
|
# Break each date into three components then merge them all (in a flat list) |
|
|
|
@ -154,10 +154,8 @@ def parallel_weekly(): |
|
|
|
|
sample = [["pos1", *[x*10+10 for x in range(len(col_names)-6)]]] |
|
|
|
|
|
|
|
|
|
myxs = {} |
|
|
|
|
# group by day; take first of each group |
|
|
|
|
#for k, g in itertools.groupby(res_all, lambda x: x[0]): |
|
|
|
|
for i, data_point in enumerate(res_all): |
|
|
|
|
#data_point = next(g) |
|
|
|
|
# group by day; take first of each group |
|
|
|
|
for i, data_point in enumerate(res_all): |
|
|
|
|
wd = list(weekdays.items())[i] |
|
|
|
|
point_id = f'{wd[1]} ({wd[0]})' |
|
|
|
|
myxs[point_id] = 'pos1' |
|
|
|
@ -187,22 +185,26 @@ def parallel_monthly(): |
|
|
|
|
table_name, col_names = get_table_cols(hus, fam, typ) |
|
|
|
|
sql_col_names = ','.join(f'"{x}"' for x in col_names) |
|
|
|
|
|
|
|
|
|
# Complex query to get each day separately |
|
|
|
|
query = f'SELECT {sql_col_names} FROM {table_name} WHERE' |
|
|
|
|
query += 'OR'.join(['(Year=? AND Month=? AND Day=?)'] * len(days)) |
|
|
|
|
query += ' GROUP BY Day;' |
|
|
|
|
|
|
|
|
|
# Break each date into three components then merge them all (in a flat list) |
|
|
|
|
params = [y for d in days for y in d.split('-')] |
|
|
|
|
|
|
|
|
|
conn = sqlite3.connect(DB_NAMES[hus]) |
|
|
|
|
query = f'SELECT {sql_col_names} FROM "{table_name}" WHERE "{date_col}" IN (?,?,?,?);' |
|
|
|
|
print(query) |
|
|
|
|
cur = conn.execute(query, days) |
|
|
|
|
cur = conn.execute(query, params) |
|
|
|
|
res_all = cur.fetchall() |
|
|
|
|
print(res_all) |
|
|
|
|
|
|
|
|
|
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 = {} |
|
|
|
|
# group by day; take first of each group |
|
|
|
|
for k, g in itertools.groupby(res_all, lambda x: x[0]): |
|
|
|
|
data_point = next(g) |
|
|
|
|
point_id = f'{data_point[0]}' |
|
|
|
|
# group by day; take first of each group |
|
|
|
|
for data_point in res_all: |
|
|
|
|
point_id = '-'.join(data_point[:3]) |
|
|
|
|
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) |
|
|
|
|