correctly decrease rolling sum starting from 0 on each day

pull/1106/head
KristianTashkov 4 years ago
parent 14599c5968
commit 7f102b2a55

@ -101,10 +101,9 @@ class ScoreList {
if (isNumerical) { if (isNumerical) {
rollingSum = defaultValue.toDouble() * denominator rollingSum = defaultValue.toDouble() * denominator
previousValue = numericalPercentageComplete(rollingSum) previousValue = numericalPercentageComplete(rollingSum)
rollingSum -= defaultValue
} else if (defaultValue == Entry.YES_MANUAL) { } else if (defaultValue == Entry.YES_MANUAL) {
previousValue = 1.0 previousValue = 1.0
rollingSum = denominator.toDouble() - 1 rollingSum = denominator.toDouble()
} }
for (i in values.indices) { for (i in values.indices) {
@ -113,7 +112,10 @@ class ScoreList {
rollingSum += values[offset] rollingSum += values[offset]
if (offset + denominator < values.size) { if (offset + denominator < values.size) {
rollingSum -= values[offset + denominator] rollingSum -= values[offset + denominator]
} else {
rollingSum -= defaultValue
} }
val percentageCompleted = numericalPercentageComplete(rollingSum) val percentageCompleted = numericalPercentageComplete(rollingSum)
previousValue = compute(freq, previousValue, percentageCompleted) previousValue = compute(freq, previousValue, percentageCompleted)
} else { } else {
@ -123,6 +125,8 @@ class ScoreList {
if (offset + denominator < values.size) { if (offset + denominator < values.size) {
if (values[offset + denominator] == Entry.YES_MANUAL) { if (values[offset + denominator] == Entry.YES_MANUAL) {
rollingSum -= 1.0 rollingSum -= 1.0
} else {
rollingSum -= defaultValue
} }
} }
if (values[offset] != Entry.SKIP) { if (values[offset] != Entry.SKIP) {

Loading…
Cancel
Save