@@ -21,6 +21,7 @@ import co.touchlab.kermit.Logger
2121import io.rebble.libpebblecommon.database.dao.DailyMovementAggregate
2222import io.rebble.libpebblecommon.database.dao.HealthAggregates
2323import io.rebble.libpebblecommon.database.dao.HealthDao
24+ import io.rebble.libpebblecommon.database.entity.HealthDataEntity
2425import io.rebble.libpebblecommon.database.entity.HealthStat
2526import io.rebble.libpebblecommon.database.entity.HealthStatDao
2627import io.rebble.libpebblecommon.util.DataBuffer
@@ -32,6 +33,7 @@ import kotlinx.datetime.TimeZone
3233import kotlinx.datetime.atStartOfDayIn
3334import kotlinx.datetime.minus
3435import kotlinx.datetime.plus
36+ import kotlinx.datetime.toLocalDateTime
3537
3638private val logger = Logger .withTag(" HealthStatsSync" )
3739
@@ -178,6 +180,23 @@ private fun movementPayload(dayStartEpochSec: Long, aggregates: HealthAggregates
178180 return buffer.array()
179181}
180182
183+ /* *
184+ * Bins a flat list of HealthDataEntity rows into per-weekday 15-minute typical-step payloads.
185+ *
186+ * For each weekday with at least MIN_DAYS_FOR_TYPICAL distinct matching days in the input,
187+ * emits a 192-byte little-endian payload of 96 UShort values. A slot's value is the average
188+ * step count across the distinct matching days that had at least one row overlapping that
189+ * slot; if zero matching days covered the slot, the value is UNKNOWN_TYPICAL_STEPS so the
190+ * watch sum-skips it. Weekdays below the threshold are omitted from the result.
191+ */
192+ internal fun buildWeekdayTypicalsFromData (
193+ allData : List <HealthDataEntity >,
194+ timeZone : TimeZone ,
195+ ): Map <DayOfWeek , ByteArray > {
196+ if (allData.isEmpty()) return emptyMap()
197+ return emptyMap()
198+ }
199+
181200// Extension functions
182201private fun Long.kilocalories (): Long = this / 1000L
183202
0 commit comments