Fixed so that the aggregation will have less of a delay

Former-commit-id: cf26badd0d108260c4c00934005599aa7aea2e47
This commit is contained in:
Daniel Collin 2015-12-21 13:27:02 +01:00
parent 3f579bdf63
commit b391e3a5e1

View file

@ -80,9 +80,9 @@ public class DataAggregatorDaemon implements HalDaemon {
logger.fine("Calculating periods... (from:"+ maxTimestampFoundForSensor +", to:"+ currentPeriodStartTimestamp +") with expected sample count: " + expectedSampleCount);
stmt = db.getPreparedStatement("SELECT *, 1 AS confidence, timestamp AS timestamp_start FROM sensor_data_raw"
+" WHERE sensor_id == ?"
+ " AND ? < timestamp"
+ " AND timestamp < ? "
+" ORDER BY timestamp ASC");
+ " AND ? < timestamp_start"
+ " AND timestamp_start < ? "
+" ORDER BY timestamp_start ASC");
stmt.setLong(1, sensorId);
stmt.setLong(2, maxTimestampFoundForSensor);
stmt.setLong(3, currentPeriodStartTimestamp);
@ -120,7 +120,7 @@ public class DataAggregatorDaemon implements HalDaemon {
stmt = db.getPreparedStatement("SELECT * FROM sensor_data_aggr"
+" WHERE sensor_id == ?"
+ " AND ? < timestamp_start"
+ " AND timestamp_start < ?"
+ " AND timestamp_start <= ?"
+ " AND timestamp_end-timestamp_start == ?"
+" ORDER BY timestamp_start ASC");
stmt.setLong(1, sensorId);