From fc78e5c0b7300a751db3673994924d4adb0418d7 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 14 Mar 2021 17:37:58 +0100 Subject: [PATCH] Stats: inRange percentage to always get a sum equal to 100% --- app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt index 2b7806468e..b59d4a40e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt @@ -18,7 +18,7 @@ class TIR(val date: Long, val lowThreshold: Double, val highThreshold: Double) { fun above() = run { above++; count++ } fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0 - fun inRangePct() = if (count > 0) (inRange.toDouble() / count * 100.0).roundToInt() else 0 + fun inRangePct() = if (count > 0) 100 - belowPct() - abovePct() else 0 fun abovePct() = if (count > 0) (above.toDouble() / count * 100.0).roundToInt() else 0 fun toText(resourceHelper: ResourceHelper, dateUtil: DateUtil): String = resourceHelper.gs(R.string.tirformat, dateUtil.dateStringShort(date), belowPct(), inRangePct(), abovePct())