Add a working SQL example to group measurements into time slots.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 1 Aug 2018 19:30:34 +0000 (21:30 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 1 Aug 2018 19:30:34 +0000 (21:30 +0200)
web/seepark_web.py

index e8b9da11dc6f0b4b20ca6c44841cc22825acb213..7f39c15eec9e07140c827e93a5b9151e8198d540 100644 (file)
@@ -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 
             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()
 
 
     return query.all()