Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Extend RiskLevelStorage (DEV) #2653

Merged
merged 2 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package de.rki.coronawarnapp.risk.storage

import de.rki.coronawarnapp.risk.RiskLevelResult
import de.rki.coronawarnapp.risk.RiskLevelTaskResult
import de.rki.coronawarnapp.risk.TraceLocationCheckInRisk
import de.rki.coronawarnapp.risk.result.AggregatedRiskPerDateResult
import de.rki.coronawarnapp.risk.storage.internal.RiskResultDatabase
import de.rki.coronawarnapp.risk.storage.internal.riskresults.PersistedRiskLevelResultDao
Expand All @@ -13,6 +14,7 @@ import de.rki.coronawarnapp.util.flow.shareLatest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import timber.log.Timber

Expand Down Expand Up @@ -126,14 +128,16 @@ abstract class BaseRiskLevelStorage constructor(
override val aggregatedRiskPerDateResults: Flow<List<AggregatedRiskPerDateResult>> by lazy {
aggregatedRiskPerDateResultTables.allEntries()
.map {
it.map {
persistedAggregatedRiskPerDateResult ->
it.map { persistedAggregatedRiskPerDateResult ->
persistedAggregatedRiskPerDateResult.toAggregatedRiskPerDateResult()
}
}
.shareLatest(tag = TAG, scope = scope)
}

override val traceLocationCheckInRiskStates: Flow<List<TraceLocationCheckInRisk>>
get() = flowOf(emptyList<TraceLocationCheckInRisk>()) // TODO("Not yet implemented")

private suspend fun insertAggregatedRiskPerDateResults(
aggregatedRiskPerDateResults: List<AggregatedRiskPerDateResult>
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.rki.coronawarnapp.risk.storage

import de.rki.coronawarnapp.risk.RiskLevelResult
import de.rki.coronawarnapp.risk.TraceLocationCheckInRisk
import de.rki.coronawarnapp.risk.result.AggregatedRiskPerDateResult
import kotlinx.coroutines.flow.Flow

Expand Down Expand Up @@ -36,6 +37,12 @@ interface RiskLevelStorage {
*/
val aggregatedRiskPerDateResults: Flow<List<AggregatedRiskPerDateResult>>

/**
* Risk level per date/day and checkIn
* Used by contact diary overview
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor: "used by" could change easily.

*/
val traceLocationCheckInRiskStates: Flow<List<TraceLocationCheckInRisk>>

suspend fun deleteAggregatedRiskPerDateResults(results: List<AggregatedRiskPerDateResult>)

suspend fun storeResult(result: RiskLevelResult)
Expand Down