Skip to content
Snippets Groups Projects
Unverified Commit da7b95bb authored by Philipp Woessner's avatar Philipp Woessner Committed by GitHub
Browse files

fixed a bug where the wieghts where capped to 30 and not the attenuationMinutes (#426)

parent 19da2aac
No related branches found
No related tags found
No related merge requests found
...@@ -17,14 +17,14 @@ object RiskLevelCalculation { ...@@ -17,14 +17,14 @@ object RiskLevelCalculation {
/** all attenuation values are capped to [TimeVariables.MAX_ATTENUATION_DURATION] */ /** all attenuation values are capped to [TimeVariables.MAX_ATTENUATION_DURATION] */
val weightedAttenuationLow = val weightedAttenuationLow =
attenuationParameters.weights.low.capped() attenuationParameters.weights.low
.times(exposureSummary.attenuationDurationsInMinutes[0]) .times(exposureSummary.attenuationDurationsInMinutes[0].capped())
val weightedAttenuationMid = val weightedAttenuationMid =
attenuationParameters.weights.mid.capped() attenuationParameters.weights.mid
.times(exposureSummary.attenuationDurationsInMinutes[1]) .times(exposureSummary.attenuationDurationsInMinutes[1].capped())
val weightedAttenuationHigh = val weightedAttenuationHigh =
attenuationParameters.weights.high.capped() attenuationParameters.weights.high
.times(exposureSummary.attenuationDurationsInMinutes[2]) .times(exposureSummary.attenuationDurationsInMinutes[2].capped())
val maximumRiskScore = exposureSummary.maximumRiskScore.toDouble() val maximumRiskScore = exposureSummary.maximumRiskScore.toDouble()
...@@ -49,7 +49,7 @@ object RiskLevelCalculation { ...@@ -49,7 +49,7 @@ object RiskLevelCalculation {
return round(riskScore.times(DECIMAL_MULTIPLIER)).div(DECIMAL_MULTIPLIER) return round(riskScore.times(DECIMAL_MULTIPLIER)).div(DECIMAL_MULTIPLIER)
} }
private fun Double.capped(): Double { private fun Int.capped(): Int {
return if (this > TimeVariables.getMaxAttenuationDuration()) { return if (this > TimeVariables.getMaxAttenuationDuration()) {
TimeVariables.getMaxAttenuationDuration() TimeVariables.getMaxAttenuationDuration()
} else { } else {
......
...@@ -118,7 +118,7 @@ object TimeVariables { ...@@ -118,7 +118,7 @@ object TimeVariables {
* This is the maximum attenuation duration value for the risk level calculation * This is the maximum attenuation duration value for the risk level calculation
* in minutes * in minutes
*/ */
private const val MAX_ATTENUATION_DURATION = 30.0 private const val MAX_ATTENUATION_DURATION = 30
/** /**
* Getter function for [MAX_ATTENUATION_DURATION] * Getter function for [MAX_ATTENUATION_DURATION]
......
...@@ -62,6 +62,17 @@ class RiskLevelCalculationTest { ...@@ -62,6 +62,17 @@ class RiskLevelCalculationTest {
assertEquals(9830.4, riskScore) assertEquals(9830.4, riskScore)
} }
@Test
fun calculateRiskScoreCapped() {
val riskScore =
RiskLevelCalculation.calculateRiskScore(
buildAttenuationDuration(0.5, 0.5, 1.0),
buildSummary(4096, 45, 45, 45)
)
assertEquals(9830.4, riskScore)
}
private fun buildAttenuationDuration( private fun buildAttenuationDuration(
high: Double, high: Double,
mid: Double, mid: Double,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment