Skip to content

Commit

Permalink
Count extreme values in today's dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Faltenreich committed Apr 1, 2024
1 parent fb5d65b commit 3792ac4
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.faltenreich.diaguard.dashboard.usecase
import com.faltenreich.diaguard.dashboard.DashboardViewState
import com.faltenreich.diaguard.datetime.factory.DateTimeFactory
import com.faltenreich.diaguard.measurement.property.MeasurementPropertyRepository
import com.faltenreich.diaguard.measurement.value.MeasurementValue
import com.faltenreich.diaguard.measurement.value.MeasurementValueRepository
import com.faltenreich.diaguard.shared.di.inject
import kotlinx.coroutines.flow.Flow
Expand All @@ -22,11 +21,19 @@ class GetTodayUseCase(
propertyId = property.id,
minDateTime = today.atStartOfDay(),
maxDateTime = today.atEndOfDay(),
).map { values: List<MeasurementValue> ->
).map { values ->
DashboardViewState.Revisit.Today(
totalCount = values.size,
hyperCount = 0, // TODO: Calculate count
hypoCount = 0, // TODO: Calculate count
hyperCount = values.count { value ->
value.type.highValue?.let { hyperValue ->
value.value > hyperValue
} ?: false
},
hypoCount = values.count { value ->
value.type.lowValue?.let { hypoValue ->
value.value < hypoValue
} ?: false
},
)
}
}
Expand Down

0 comments on commit 3792ac4

Please sign in to comment.