Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cwa App Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Foertsch
Cwa App Android
Commits
29a8f7e4
Unverified
Commit
29a8f7e4
authored
4 years ago
by
BMItter
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adjusted getting infos for additionalRiskCalcInfo (#1684)
Co-authored-by:
Matthias Urhahn
<
matthias.urhahn@sap.com
>
parent
af008947
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt
+33
-10
33 additions, 10 deletions
...klevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt
with
33 additions
and
10 deletions
Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt
+
33
−
10
View file @
29a8f7e4
...
...
@@ -35,11 +35,13 @@ import de.rki.coronawarnapp.util.ui.SingleLiveEvent
import
de.rki.coronawarnapp.util.viewmodel.CWAViewModel
import
de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactory
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.flow.combine
import
kotlinx.coroutines.flow.map
import
kotlinx.coroutines.flow.sample
import
kotlinx.coroutines.withContext
import
org.joda.time.Instant
import
timber.log.Timber
import
java.util.Date
import
java.util.concurrent.TimeUnit
class
TestRiskLevelCalculationFragmentCWAViewModel
@AssistedInject
constructor
(
...
...
@@ -63,7 +65,6 @@ class TestRiskLevelCalculationFragmentCWAViewModel @AssistedInject constructor(
Timber
.
d
(
"Example arg: %s"
,
exampleArg
)
}
val
startLocalQRCodeScanEvent
=
SingleLiveEvent
<
Unit
>()
val
riskLevelResetEvent
=
SingleLiveEvent
<
Unit
>()
val
showRiskStatusCard
=
SubmissionRepository
.
deviceUIStateFlow
.
map
{
...
...
@@ -126,16 +127,38 @@ class TestRiskLevelCalculationFragmentCWAViewModel @AssistedInject constructor(
.
appendLine
(
normalizedTimePerDayToRiskLevelMappingList
)
.
toString
()
// Only update when risk level gets updated
val
additionalRiskCalcInfo
=
RiskLevelRepository
.
riskLevelScore
.
map
{
createAdditionalRiskCalcInfo
(
it
)
}
.
asLiveData
()
private
suspend
fun
createAdditionalRiskCalcInfo
(
riskLevelScore
:
Int
):
String
=
StringBuilder
()
val
additionalRiskCalcInfo
=
combine
(
RiskLevelRepository
.
riskLevelScore
,
RiskLevelRepository
.
riskLevelScoreLastSuccessfulCalculated
,
exposureResultStore
.
matchedKeyCount
,
exposureResultStore
.
daysSinceLastExposure
,
LocalData
.
lastTimeDiagnosisKeysFromServerFetchFlow
()
)
{
riskLevelScore
,
riskLevelScoreLastSuccessfulCalculated
,
matchedKeyCount
,
daysSinceLastExposure
,
lastTimeDiagnosisKeysFromServerFetch
->
createAdditionalRiskCalcInfo
(
riskLevelScore
=
riskLevelScore
,
riskLevelScoreLastSuccessfulCalculated
=
riskLevelScoreLastSuccessfulCalculated
,
matchedKeyCount
=
matchedKeyCount
,
daysSinceLastExposure
=
daysSinceLastExposure
,
lastTimeDiagnosisKeysFromServerFetch
=
lastTimeDiagnosisKeysFromServerFetch
)
}.
asLiveData
()
private
suspend
fun
createAdditionalRiskCalcInfo
(
riskLevelScore
:
Int
,
riskLevelScoreLastSuccessfulCalculated
:
Int
,
matchedKeyCount
:
Int
,
daysSinceLastExposure
:
Int
,
lastTimeDiagnosisKeysFromServerFetch
:
Date
?
):
String
=
StringBuilder
()
.
appendLine
(
"Risk Level: ${RiskLevel.forValue(riskLevelScore)}"
)
.
appendLine
(
"Last successful Risk Level: ${RiskLevelRepository.getLastSuccessfullyCalculatedScore()}"
)
.
appendLine
(
"Last Time Server Fetch: ${LocalData.lastTimeDiagnosisKeysFromServerFetch()}"
)
.
appendLine
(
"Last successful Risk Level: ${RiskLevel.forValue(riskLevelScoreLastSuccessfulCalculated)}"
)
.
appendLine
(
"Matched key count: $matchedKeyCount"
)
.
appendLine
(
"Days since last Exposure: $daysSinceLastExposure days"
)
.
appendLine
(
"Last Time Server Fetch: ${lastTimeDiagnosisKeysFromServerFetch?.time?.let { Instant.ofEpochMilli(it) }}"
)
.
appendLine
(
"Tracing Duration: ${TimeUnit.MILLISECONDS.toDays(TimeVariables.getTimeActiveTracingDuration())} days"
)
.
appendLine
(
"Tracing Duration in last 14 days: ${TimeVariables.getActiveTracingDaysInRetentionPeriod()} days"
)
.
appendLine
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment