Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup algorithm doesn't look good for me #47

Open
ajsergeev opened this issue Feb 13, 2018 · 0 comments
Open

Rollup algorithm doesn't look good for me #47

ajsergeev opened this issue Feb 13, 2018 · 0 comments

Comments

@ajsergeev
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant