Skip to content

Commit 5b32e99

Browse files
committed
Add backoff time when no records are found
1 parent 9971d00 commit 5b32e99

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

oura-library/src/main/kotlin/org/radarbase/oura/request/OuraRequestGenerator.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ constructor(
145145
?: nextRequestTime
146146
} else {
147147
if (request.startDate.plus(TIME_AFTER_REQUEST).isBefore(Instant.now())) {
148+
logger.info("No records found, updating offsets to end date..")
148149
ouraOffsetManager.updateOffsets(
149150
request.route,
150151
request.user,
151152
request.endDate,
152153
)
154+
userNextRequest[request.user.versionedId] = Instant.now().plus(BACK_OFF_TIME)
153155
}
154156
}
155157
return records
@@ -241,7 +243,7 @@ constructor(
241243
private val logger = LoggerFactory.getLogger(OuraRequestGenerator::class.java)
242244
private val BACK_OFF_TIME = Duration.ofMinutes(10L)
243245
private val ONE_DAY = 1L
244-
private val TIME_AFTER_REQUEST = Duration.ofDays(30)
246+
private val TIME_AFTER_REQUEST = Duration.ofDays(10)
245247
private val USER_BACK_OFF_TIME = Duration.ofHours(12L)
246248
private val SUCCESS_BACK_OFF_TIME = Duration.ofMinutes(1L)
247249
private val USER_MAX_REQUESTS = 20

0 commit comments

Comments
 (0)