Skip to content

Commit

Permalink
Merge pull request #58 from RADAR-base/fix_sleep_score
Browse files Browse the repository at this point in the history
fix summaryId parsing in sleepScore
  • Loading branch information
yatharthranjan authored May 16, 2023
2 parents 2f59ef6 + 53dc9ae commit d24cd01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/main/kotlin/org/radarbase/gateway/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data class GarminConfig(
if (enabled) {
check(GarminUserRepository::class.java.isAssignableFrom(userRepository)) {
"$userRepositoryClass is not valid. Please specify a class that is a subclass of" +
" `org.radarbase.push.integration.garmin.user.GarminUserRepository`"
" `org.radarbase.push.integration.garmin.user.GarminUserRepository`"
}
}
}
Expand All @@ -91,7 +91,9 @@ data class BackfillConfig(
val redis: RedisConfig = RedisConfig(),
val maxThreads: Int = 4,
val defaultEndDate: Instant = Instant.MAX,
val userBackfill: List<UserBackfillConfig> = emptyList()
val userBackfill: List<UserBackfillConfig> = emptyList(),
val requestsPerUserPerIteration: Int = 40,
val iterationIntervalMinutes: Long = 5,
)

data class RedisConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SleepScoreGarminAvroConverter(

private fun getRecord(node: JsonNode): SpecificRecord {
return GarminSleepScoreSample.newBuilder().apply {
summaryId = summaryId
summaryId = node["summaryId"]?.asText()
time = node["startTimeInSeconds"].asDouble()
startTimeOffset = node["startTimeOffsetInSeconds"]?.asInt()
timeReceived = Instant.now().toEpochMilli() / 1000.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BackfillService(
)

private val requestsPerUserPerIteration: Int
get() = 40
get() = config.pushIntegration.garmin.backfill.requestsPerUserPerIteration

private val futures: MutableList<Future<*>> = mutableListOf()

Expand All @@ -64,7 +64,12 @@ class BackfillService(
private fun start() {
logger.info("Application Initialisation completed. Starting Backfill service...")

executorService.scheduleAtFixedRate(::iterateUsers, 1, 5, TimeUnit.MINUTES)
executorService.scheduleAtFixedRate(
::iterateUsers,
1,
config.pushIntegration.garmin.backfill.iterationIntervalMinutes,
TimeUnit.MINUTES
)
}

private fun stop() {
Expand Down Expand Up @@ -124,6 +129,5 @@ class BackfillService(

companion object {
private val logger = LoggerFactory.getLogger(BackfillService::class.java)
private const val WAIT_TIME_MS = 10_000L
}
}

0 comments on commit d24cd01

Please sign in to comment.