From: Philipp Spitzer Date: Wed, 1 Aug 2018 19:30:34 +0000 (+0200) Subject: Add a working SQL example to group measurements into time slots. X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/commitdiff_plain/7ca34f80f45e96873eca14f00a31d49f06bf31e1?hp=07f6fd2c6041d6203380a60771ce1cffdc2f68a7 Add a working SQL example to group measurements into time slots. --- diff --git a/web/seepark_web.py b/web/seepark_web.py index e8b9da1..7f39c15 100644 --- a/web/seepark_web.py +++ b/web/seepark_web.py @@ -92,18 +92,7 @@ def select_sensordata(sensor_id, sensor_type, begin, end, mode): resolution = resolutions['year'] # TODO: filter out samples from 'result' # something like - # select mean(temperature) from sensors where ... group by mod(timestamp, resolution) - # func.avg(...) - # - # from https://stackoverflow.com/questions/4342370/grouping-into-interval-of-5-minutes-within-a-time-range - # SELECT - # timestamp, -- not sure about that - # name, - # count(b.name) - # FROM time a, id - # WHERE … - # GROUP BY - # UNIX_TIMESTAMP(timestamp) DIV 300, name + # select to_seconds(datetime) DIV (60*60*24) as interval_id, min(datetime), max(datetime), min(temp), avg(temp), max(temp), count(temp) from openweathermap group by interval_id order by interval_id; return query.all()