Adjust windows, return avg air data

This commit is contained in:
2026-08-25 20:51:59 +00:00
parent 4e24836aec
commit 154b4d4c88
+2 -2
View File
@@ -495,7 +495,7 @@ async def history(request):
raise raise
window = request.rel_url.query.get('window', window) window = request.rel_url.query.get('window', window)
if window not in ['1m', '3m', '10m', '30m', '1h', '2h', '1d', '7d', '30d']: if window not in ['1m', '3m', '5m', '10m', '30m', '1h', '2h', '1d', '7d', '30d']:
raise raise
start = int(start.timestamp()) start = int(start.timestamp())
@@ -531,7 +531,7 @@ async def history(request):
q = 'select max("avg_p10") as max_p10, max("avg_p25") as max_p25 from dust where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window) q = 'select max("avg_p10") as max_p10, max("avg_p25") as max_p25 from dust where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
elif measurement == 'air': elif measurement == 'air':
client = sensors_client client = sensors_client
q = 'select max("pm10") as max_p10, max("pm25") as max_p25, max("co2") as max_co2, max("voc_idx") as max_voc from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window) q = 'select mean("pm10") as p10, mean("pm25") as p25, mean("co2") as co2, mean("voc_idx") as voc from air where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)
elif measurement == 'soil': elif measurement == 'soil':
client = sensors_client client = sensors_client
q = 'select mean("soil") as soil, mean("moisture") as moisture from soil where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window) q = 'select mean("soil") as soil, mean("moisture") as moisture from soil where "name" = \'{}\' and time >= {}s and time < {}s group by time({}) fill(linear)'.format(name, start, end, window)