Skip to content

Commit 5d87b76

Browse files
Refactor checking of end date for brevity
Co-authored-by: Yatharth Ranjan <[email protected]>
1 parent 2e0cd88 commit 5d87b76

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,7 @@ constructor(
8989
logger.info("Offsets found in persistence: " + offsetTime.toString())
9090
offsetTime.coerceAtLeast(startDate)
9191
}
92-
val endDate = user.endDate!!.let {
93-
if (user.endDate == null) {
94-
Instant.now()
95-
}
96-
else {
97-
if (it >= Instant.now()) {
98-
Instant.now()
99-
}
100-
it
101-
}
102-
}
92+
val endDate = user.endDate?.coerceAtMost(Instant.now()) ?: Instant.now()
10393
if (Duration.between(startOffset, endDate) <= ONE_DAY) {
10494
logger.info("Interval between dates is too short. Backing off..")
10595
userNextRequest[user.versionedId] = Instant.now().plus(USER_BACK_OFF_TIME)

0 commit comments

Comments
 (0)