Merge pull request #958 from triplem/refix_objectives

Fixes wrong algo
This commit is contained in:
Milos Kozak 2018-05-02 07:38:03 +02:00 committed by GitHub
commit 55db89b547
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 17 deletions

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.T;
public class ObjectivesFragment extends SubscriberFragment { public class ObjectivesFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class); private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
@ -204,7 +205,7 @@ public class ObjectivesFragment extends SubscriberFragment {
return 1; return 1;
} else if (objectiveStartedTime > 0 && !enableFakeValue } else if (objectiveStartedTime > 0 && !enableFakeValue
&& objectiveAccomplishedTime == 0 && objectiveAccomplishedTime == 0
&& !(objectiveStartedTime + durationInDays * 24 * 60 * 60 * 1000 >= now && requirementsMet)) { && !(objectiveStartedTime + T.days(durationInDays).msecs() < now && requirementsMet)) {
return 2; return 2;
} else if (objectiveAccomplishedTime == 0) { } else if (objectiveAccomplishedTime == 0) {
return 3; return 3;

View file

@ -35,25 +35,10 @@ public class ObjectivesFragmentTest {
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue)); objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
// started // started
// time calculation is false, requirements met is false // time calculation is true, requirements met is true
objectiveStartedTime = 10; objectiveStartedTime = 10;
durationInDays = 0; durationInDays = 0;
requirementsMet = true; requirementsMet = true;
assertEquals(2, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
// started
// time calculation is false, requirements met is true
objectiveStartedTime = 10;
durationInDays = 999999;
requirementsMet = true;
assertEquals(2, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
// started, after duration, requirements met --> show verify
objectiveStartedTime = Long.MAX_VALUE;
durationInDays = 0;
requirementsMet = true;
assertEquals(3, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime, assertEquals(3, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue)); objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));