groupBy: fill empty intervals by null, closes #388

This commit is contained in:
Alexander Zobnin
2017-07-03 12:03:17 +03:00
parent 007ddbf72f
commit badc5e4cb9
4 changed files with 25 additions and 7 deletions

View File

@@ -121,10 +121,16 @@ function groupBy_perf(datapoints, interval, groupByCallback) {
point_frame_ts = getPointTimeFrame(point[POINT_TIMESTAMP], ms_interval);
if (point_frame_ts === frame_ts) {
frame_values.push(point[POINT_VALUE]);
} else {
} else if (point_frame_ts > frame_ts) {
frame_value = groupByCallback(frame_values);
grouped_series.push([frame_value, frame_ts]);
frame_ts = point_frame_ts;
// Move frame window to next non-empty interval and fill empty by null
frame_ts += ms_interval;
while (frame_ts < point_frame_ts) {
grouped_series.push([null, frame_ts]);
frame_ts += ms_interval;
}
frame_values = [point[POINT_VALUE]];
}
}