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 {
/** all attenuation values are capped to [TimeVariables.MAX_ATTENUATION_DURATION] */
val weightedAttenuationLow =
attenuationParameters.weights.low.capped()
.times(exposureSummary.attenuationDurationsInMinutes[0])
attenuationParameters.weights.low
.times(exposureSummary.attenuationDurationsInMinutes[0].capped())
val weightedAttenuationMid =
attenuationParameters.weights.mid.capped()
.times(exposureSummary.attenuationDurationsInMinutes[1])
attenuationParameters.weights.mid
.times(exposureSummary.attenuationDurationsInMinutes[1].capped())
val weightedAttenuationHigh =
attenuationParameters.weights.high.capped()
.times(exposureSummary.attenuationDurationsInMinutes[2])
attenuationParameters.weights.high
.times(exposureSummary.attenuationDurationsInMinutes[2].capped())
val maximumRiskScore = exposureSummary.maximumRiskScore.toDouble()
......@@ -49,7 +49,7 @@ object RiskLevelCalculation {
return round(riskScore.times(DECIMAL_MULTIPLIER)).div(DECIMAL_MULTIPLIER)
}
private fun Double.capped(): Double {
private fun Int.capped(): Int {
return if (this > TimeVariables.getMaxAttenuationDuration()) {
TimeVariables.getMaxAttenuationDuration()
} else {
......
......@@ -118,7 +118,7 @@ object TimeVariables {
* This is the maximum attenuation duration value for the risk level calculation
* in minutes
*/
private const val MAX_ATTENUATION_DURATION = 30.0
private const val MAX_ATTENUATION_DURATION = 30
/**
* Getter function for [MAX_ATTENUATION_DURATION]
......
......@@ -62,6 +62,17 @@ class RiskLevelCalculationTest {
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(
high: 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