Skip to content

Commit 2c3bc7e

Browse files
authored
Merge pull request #143 from RADAR-base/feat/allow-null-end
Allow null end dates in Oura
2 parents 67af964 + 5d87b76 commit 2c3bc7e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ constructor(
8989
logger.info("Offsets found in persistence: " + offsetTime.toString())
9090
offsetTime.coerceAtLeast(startDate)
9191
}
92-
val endDate = if (user.endDate >= Instant.now()) Instant.now() else user.endDate
92+
val endDate = user.endDate?.coerceAtMost(Instant.now()) ?: Instant.now()
9393
if (Duration.between(startOffset, endDate) <= ONE_DAY) {
9494
logger.info("Interval between dates is too short. Backing off..")
9595
userNextRequest[user.versionedId] = Instant.now().plus(USER_BACK_OFF_TIME)

oura-library/src/main/kotlin/org/radarbase/oura/user/OuraUser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ data class OuraUser(
1616
@JsonProperty("externalId") override val externalId: String?,
1717
@JsonProperty("isAuthorized") override val isAuthorized: Boolean,
1818
@JsonProperty("startDate") override val startDate: Instant,
19-
@JsonProperty("endDate") override val endDate: Instant,
19+
@JsonProperty("endDate") override val endDate: Instant? = null,
2020
@JsonProperty("version") override val version: String? = null,
2121
@JsonProperty("serviceUserId") override val serviceUserId: String? = null,
2222
) : User {

oura-library/src/main/kotlin/org/radarbase/oura/user/User.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface User {
1010
val sourceId: String
1111
val externalId: String?
1212
val startDate: Instant
13-
val endDate: Instant
13+
val endDate: Instant?
1414
val createdAt: Instant
1515
val humanReadableUserId: String?
1616
val serviceUserId: String?

0 commit comments

Comments
 (0)