mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Make skips freeze score (#630)
This commit is contained in:
@@ -286,7 +286,7 @@ public abstract class ScoreList implements Iterable<Score>
|
||||
double percentageCompleted = Math.min(1, rollingSum / 1000 / habit.getTargetValue());
|
||||
previousValue = Score.compute(1.0, previousValue, percentageCompleted);
|
||||
}
|
||||
else
|
||||
else if (checkmarkValues[offset] != Checkmark.SKIP)
|
||||
{
|
||||
double value = Math.min(1, checkmarkValues[offset]);
|
||||
previousValue = Score.compute(freq, previousValue, value);
|
||||
|
||||
@@ -125,6 +125,49 @@ public class ScoreListTest extends BaseUnitTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getValueWithSkip()
|
||||
{
|
||||
toggleRepetitions(0, 20);
|
||||
addSkip(5);
|
||||
addSkip(10);
|
||||
addSkip(11);
|
||||
|
||||
double expectedValues[] = {
|
||||
0.596033,
|
||||
0.573910,
|
||||
0.550574,
|
||||
0.525961,
|
||||
0.500000,
|
||||
0.472617,
|
||||
0.472617,
|
||||
0.443734,
|
||||
0.413270,
|
||||
0.381137,
|
||||
0.347244,
|
||||
0.347244,
|
||||
0.347244,
|
||||
0.311495,
|
||||
0.273788,
|
||||
0.234017,
|
||||
0.192067,
|
||||
0.147820,
|
||||
0.101149,
|
||||
0.051922,
|
||||
0.000000,
|
||||
0.000000,
|
||||
0.000000
|
||||
};
|
||||
|
||||
ScoreList scores = habit.getScores();
|
||||
Timestamp current = DateUtils.getToday();
|
||||
for (double expectedValue : expectedValues)
|
||||
{
|
||||
assertThat(scores.getValue(current), closeTo(expectedValue, E));
|
||||
current = current.minus(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getValues()
|
||||
{
|
||||
@@ -197,4 +240,11 @@ public class ScoreListTest extends BaseUnitTest
|
||||
for (int i = from; i < to; i++)
|
||||
reps.toggle(today.minus(i));
|
||||
}
|
||||
|
||||
private void addSkip(final int day)
|
||||
{
|
||||
RepetitionList reps = habit.getRepetitions();
|
||||
Timestamp today = DateUtils.getToday();
|
||||
reps.toggle(today.minus(day), Checkmark.SKIP);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user