Skip to content
Closed
Show file tree
Hide file tree
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 @@ -64,12 +64,18 @@ protected Stream<TopicData> processRecords(

// Used as the date to convert the local times in the dataset to absolute times.
ZonedDateTime startDate = request.getDateRange().start();
Instant rangeStart = startDate.toInstant();
Instant rangeEnd = request.getDateRange().end().toInstant();

return iterableToStream(dataset)
.map(tryOrNull(activity -> {
Instant time = startDate.with(LocalTime.parse(activity.get("time").asText()))
.toInstant();

if (time.isBefore(rangeStart) || !time.isBefore(rangeEnd)) {
return null;
}

FitbitIntradayHeartRate heartRate = new FitbitIntradayHeartRate(
time.toEpochMilli() / 1000d,
timeReceived,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.radarbase.connect.rest.fitbit.route;

import static java.time.format.DateTimeFormatter.ISO_LOCAL_TIME;
import static java.time.temporal.ChronoUnit.DAYS;
import static java.time.temporal.ChronoUnit.SECONDS;

import io.confluent.connect.avro.AvroData;
Expand Down Expand Up @@ -46,8 +46,10 @@ protected Stream<FitbitRestRequest> createRequests(User user) {
return startDateGenerator(getOffset(user).plus(ONE_SECOND).truncatedTo(SECONDS))
.map(dateRange -> newRequest(user, dateRange,
user.getExternalUserId(), DATE_FORMAT.format(dateRange.start()),
ISO_LOCAL_TIME.format(dateRange.start()),
ISO_LOCAL_TIME.format(dateRange.end().truncatedTo(SECONDS))));
// Always request full day boundaries
TIME_FORMAT.format(dateRange.start().truncatedTo(DAYS).truncatedTo(SECONDS)),
TIME_FORMAT.format(dateRange.start().truncatedTo(DAYS).plusDays(1).minusNanos(1)
.truncatedTo(SECONDS))));
}

@Override
Expand Down