Skip to content

Rollup algorithm doesn't look good for me #47

@ajsergeev

Description

@ajsergeev

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

  1. if point out of interval, it gets included into interval
  2. beginning of the next interval is last point not included in the previous interval
  3. lastTimestamp goes to the result

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions