-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Unsynced Time Limit to be set in hours #2744
Conversation
@damagatchi retest this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The math looks good. Nice that the inverted days_ago variable goes away.
@@ -152,12 +152,13 @@ private static boolean unsentFormNumberLimitExceeded(int numUnsentForms) { | |||
|
|||
private static boolean unsentFormTimeLimitExceeded(long lastSyncTime) { | |||
SharedPreferences prefs = CommCareApplication.instance().getCurrentApp().getAppPreferences(); | |||
int unsentFormTimeLimit = Integer.parseInt(prefs.getString(UNSENT_FORM_TIME_KEY, "5")); | |||
double unsentFormTimeLimitInDays = Double.parseDouble(prefs.getString(UNSENT_FORM_TIME_KEY, "5")); | |||
int unsentFormTimeLimitInMinutes = (int)(unsentFormTimeLimitInDays * 24 * 60); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about converting this to seconds instead of minutes for even better precision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or miliseconds?
that way you avoid any conversion in the comparison later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I battled with the same question myself and ended up settling with minutes.
This makes it possible to set limits shorter than a day. The property Unsynced Time Limit is expressed in days, a decimal number will result in frequencies lower than 24 hours.
c851dfc
to
efd46d6
Compare
efd46d6
to
0e39881
Compare
|
||
return minutesSinceLastSync > unsentFormTimeLimitInMinutes; | ||
return msecsSinceLastSync > unsentFormTimeLimitInMsecs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @avazirna , I will leave the review to mobile team.
Summary
Currently, the minimum frequency for CommCare to warn users that a sync is needed is daily, this PR allows setting time limits shorter than that. The property
Unsynced Time Limit
is expressed in days, so this change makes it possible to pass down a decimal number resulting in frequencies lower than 24 hours, when the value is lower than1
.Ticket: https://dimagi.atlassian.net/browse/SC-3223
Safety Assurance
Automated test coverage
Unit tests don't cover this logic. I was tempted to add some, but this code lives in a private method so I would need to broaden the scope of the test.