Skip to content

Commit c1b8147

Browse files
committed
fix: set offset for resting heart rate to one day later
1 parent 3b7a7fc commit c1b8147

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kafka-connect-fitbit-source/src/main/java/org/radarbase/connect/rest/fitbit/route/FitbitRestingHeartRateRoute.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
package org.radarbase.connect.rest.fitbit.route;
1919

2020
import static java.time.ZoneOffset.UTC;
21-
import static java.time.temporal.ChronoUnit.SECONDS;
21+
import static java.time.temporal.ChronoUnit.DAYS;
2222

2323
import io.confluent.connect.avro.AvroData;
2424

2525
import java.time.Duration;
2626
import java.time.ZonedDateTime;
27-
import java.time.format.DateTimeFormatter;
2827
import java.util.stream.Stream;
2928

3029
import org.radarbase.connect.rest.fitbit.converter.FitbitRestingHeartRateAvroConverter;
@@ -47,9 +46,14 @@ public FitbitRestingHeartRateRoute(
4746

4847
@Override
4948
protected Stream<FitbitRestRequest> createRequests(User user) {
50-
ZonedDateTime startDate = this.getOffset(user).plus(ONE_SECOND)
49+
// Important: resting heart rate is queried at the resolution of a single
50+
// day, so the offset for the next request will be set to the next day.
51+
ZonedDateTime startDate = this.getOffset(user).plus(ONE_DAY)
5152
.atZone(UTC)
52-
.truncatedTo(SECONDS);
53+
.truncatedTo(DAYS);
54+
// Note: the date range of startDate to now() is not correct, but will ensure that in case of empty
55+
// results, the HISTORICAL_TIME_DAYS retry inactivation in requestEmpty() of FitbitPollingRoute.java
56+
// will never be used.
5357
return Stream.of(newRequest(user, new DateRange(startDate, ZonedDateTime.now(UTC)),
5458
user.getExternalUserId(), DATE_FORMAT.format(startDate)));
5559
}

0 commit comments

Comments
 (0)