Browse Source

Quick and dirty calorie scale option

main 2.8.0
Stian Fredrik Aune 8 months ago
parent
commit
5730609665
  1. 4
      ykonsole-exporter/src/main/kotlin/net/aiterp/git/ykonsole2/infrastructure/indigo2/Indigo2.kt
  2. 2
      ykonsole-server/src/main/kotlin/net/aiterp/git/ykonsole2/Server.kt

4
ykonsole-exporter/src/main/kotlin/net/aiterp/git/ykonsole2/infrastructure/indigo2/Indigo2.kt

@ -20,6 +20,7 @@ import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
import java.util.*
import kotlin.math.roundToInt
class Indigo2(
private val indigoHost: String,
@ -27,6 +28,7 @@ class Indigo2(
private val oidcClientId: String,
private val oidcClientSecret: String,
private val autoClaim: Boolean,
private val calorieScale: Double = 1.0,
) : ExportTarget {
private val om = jacksonObjectMapper().apply {
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
@ -162,7 +164,7 @@ class Indigo2(
if (ws.time.seconds > 0) mapOf(
"seconds" to ws.time.toInt(),
"meters" to ws.distance?.toInt(),
"calories" to ws.calories?.toInt(),
"calories" to ws.calories?.toInt()?.let { (it * calorieScale).roundToInt() },
"resistance" to ws.level?.toInt(),
"rpmSpeed" to ws.rpmSpeed?.toInt(),
"pulse" to ws.pulse?.toInt(),

2
ykonsole-server/src/main/kotlin/net/aiterp/git/ykonsole2/Server.kt

@ -112,6 +112,7 @@ private data class RepositorySet(
val clientId = strEnv("INDIGO2_OIDC_CLIENT_ID")
val clientSecret = strEnv("INDIGO2_OIDC_CLIENT_SECRET")
val autoClaim = (optStrEnv("INDIGO2_OIDC_AUTO_CLAIM")?.lowercase() ?: "false") in arrayOf("yes", "1", "true")
val calorieScale = (optStrEnv("INDIGO2_EXPORT_CALORIE_SCALE")?.toDoubleOrNull()) ?: 1.0
return Indigo2(
indigoHost = indigo2Endpoint,
@ -119,6 +120,7 @@ private data class RepositorySet(
oidcClientId = clientId,
oidcClientSecret = clientSecret,
autoClaim = autoClaim,
calorieScale = calorieScale,
)
}

Loading…
Cancel
Save