|
|
@ -75,13 +75,12 @@ class ScoreList {
|
|
|
|
to: Timestamp,
|
|
|
|
to: Timestamp,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
map.clear()
|
|
|
|
map.clear()
|
|
|
|
if (computedEntries.getKnown().isEmpty()) return
|
|
|
|
|
|
|
|
if (from.isNewerThan(to)) return
|
|
|
|
|
|
|
|
var rollingSum = 0.0
|
|
|
|
var rollingSum = 0.0
|
|
|
|
var numerator = frequency.numerator
|
|
|
|
var numerator = frequency.numerator
|
|
|
|
var denominator = frequency.denominator
|
|
|
|
var denominator = frequency.denominator
|
|
|
|
val freq = frequency.toDouble()
|
|
|
|
val freq = frequency.toDouble()
|
|
|
|
val values = computedEntries.getByInterval(from, to).map { it.value }.toIntArray()
|
|
|
|
val values = computedEntries.getByInterval(from, to).map { it.value }.toIntArray()
|
|
|
|
|
|
|
|
val isAtMost = numericalHabitType == NumericalHabitType.AT_MOST
|
|
|
|
|
|
|
|
|
|
|
|
// For non-daily boolean habits, we double the numerator and the denominator to smooth
|
|
|
|
// For non-daily boolean habits, we double the numerator and the denominator to smooth
|
|
|
|
// out irregular repetition schedules (for example, weekly habits performed on different
|
|
|
|
// out irregular repetition schedules (for example, weekly habits performed on different
|
|
|
@ -91,7 +90,7 @@ class ScoreList {
|
|
|
|
denominator *= 2
|
|
|
|
denominator *= 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var previousValue = 0.0
|
|
|
|
var previousValue = if (isNumerical && isAtMost) 1.0 else 0.0
|
|
|
|
for (i in values.indices) {
|
|
|
|
for (i in values.indices) {
|
|
|
|
val offset = values.size - i - 1
|
|
|
|
val offset = values.size - i - 1
|
|
|
|
if (isNumerical) {
|
|
|
|
if (isNumerical) {
|
|
|
@ -101,7 +100,7 @@ class ScoreList {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val normalizedRollingSum = rollingSum / 1000
|
|
|
|
val normalizedRollingSum = rollingSum / 1000
|
|
|
|
val percentageCompleted = if (numericalHabitType == NumericalHabitType.AT_LEAST) {
|
|
|
|
val percentageCompleted = if (!isAtMost) {
|
|
|
|
if (targetValue > 0)
|
|
|
|
if (targetValue > 0)
|
|
|
|
min(1.0, normalizedRollingSum / targetValue)
|
|
|
|
min(1.0, normalizedRollingSum / targetValue)
|
|
|
|
else
|
|
|
|
else
|
|
|
|