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

Trim most recent data #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class SensorQueryParameters {
private final DateTime end;
private final Integer slotDuration;

public SensorQueryParameters(DateTime start, DateTime end, Integer slotDuration) {
public SensorQueryParameters(final DateTime start, final DateTime end, final Integer slotDuration) {
this.start = start;
this.end = end;
this.slotDuration = slotDuration;
Expand All @@ -28,14 +28,14 @@ public Integer slotDuration() {
}

public static SensorQueryParameters from(final QueryScope scope, final DateTime refUTC) {

final DateTime end = refUTC.minusMinutes(3); // should trim the most recent minutes to avoid empty data
switch(scope) {
case DAY_5_MINUTE:
return new SensorQueryParameters(refUTC.minusHours(24), refUTC, 5);
return new SensorQueryParameters(refUTC.minusHours(24), end, 5);
case LAST_3H_5_MINUTE:
return new SensorQueryParameters(refUTC.minusHours(3), refUTC, 5);
return new SensorQueryParameters(refUTC.minusHours(3), end, 5);
case WEEK_1_HOUR:
return new SensorQueryParameters(refUTC.minusDays(7), refUTC, 60);
return new SensorQueryParameters(refUTC.minusDays(7), end, 60);
default:
throw new IllegalArgumentException("not supported");
}
Expand Down