Rollup algorithm doesn't look good for me
Opened this issue · 0 comments
ajsergeev commented
await for (ValuePair pair in fetchHistoryData(range)) {
rollup.add(pair.value);
if (lastTimestamp != -1) {
totalTime += pair.time.millisecondsSinceEpoch - lastTimestamp;
}
lastTimestamp = pair.time.millisecondsSinceEpoch;
if (totalTime >= interval.inMilliseconds) {
totalTime = 0;
result = new ValuePair(
new DateTime.fromMillisecondsSinceEpoch(
lastTimestamp
).toIso8601String(),
rollup.value
);
yield result;
result = null;
rollup.reset();
}
}
What I don't like
- if point out of interval, it gets included into interval
- beginning of the next interval is last point not included in the previous interval
- lastTimestamp goes to the result