Skip to content
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

Boresha Afya Fixes: Saving a Family takes more than 5mins #137

Merged
merged 4 commits into from
Aug 24, 2022

Conversation

owais-vd
Copy link
Contributor

@owais-vd owais-vd commented Jul 22, 2022

@owais-vd owais-vd requested a review from ekigamba July 22, 2022 08:53
@owais-vd owais-vd requested review from hilpitome and allan-on July 22, 2022 12:16
public class HfSyncTaskIntentService extends SyncTaskIntentService {
@Override
protected void onHandleIntent(Intent intent) {
HfTaskServiceHelper taskServiceHelper = HfTaskServiceHelper.getInstance();
taskServiceHelper.syncTasks();
SyncTaskWithClientEventsServiceJob.scheduleJobImmediately(SyncTaskWithClientEventsServiceJob.TAG);
scheduleJob(SyncTaskWithClientEventsServiceJob.TAG, 15L, 5L);
Copy link
Collaborator

@allan-on allan-on Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@owais-vd owais-vd Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to have a bug in scheduleJob() method we are passing the start param as a minute and matching the condition with milliseconds.

https://github.com/opensrp/opensrp-client-core/blob/d24dc795ad2e2583447ef59042c0afb0691ae154/opensrp-core/src/main/java/org/smartregister/job/BaseJob.java#L26
Line no 26 will always return false.

I think we need to convert start to TimeUnit.MINUTES.toMillis(start) in client-core library.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @owais-vd
Yes, it appears the comparison boolean toReschedule = start < TimeUnit.MINUTES.toMillis(15); is evaluated as TimeUnit.MINUTES.toMinutes(15) < TimeUnit.MINUTES.toMillis(start).
Won't this always result to toReschedule as true?

Copy link
Contributor Author

@owais-vd owais-vd Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimeUnit.MINUTES.toMinutes(15) always return minutes no conversion would be done because we are converting minutes to minutes.

For example:
TimeUnit.MINUTES.toMinutes(15) return 15 and TimeUnit.MINUTES.toMillis(15) return 900000. Therefore, toReschedule will always true.

Line no 26 should be changed to boolean toReschedule = TimeUnit.MINUTES.toMillis(start) < TimeUnit.MINUTES.toMillis(15);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The change makes sense

@ekigamba
Copy link
Contributor

@owais-vd Can you provide a description on what the issue was and the fix?

@owais-vd
Copy link
Contributor Author

@owais-vd Can you provide a description on what the issue was and the fix?

on the application load, SyncTaskWithClientEventsServiceJob job schedule immediately and blocked the processClient method. i made the schedule with delay to prevent the processClient method from being blocked.

@allan-on
Copy link
Collaborator

Hi @owais-vd
The boolean toReschedule = TimeUnit.MINUTES.toMillis(start) < TimeUnit.MINUTES.toMillis(15); change makes sense.
Did you try testing a fix with scheduling periodically instead prior to writing the custom implementation?

@owais-vd
Copy link
Contributor Author

Hi @owais-vd The boolean toReschedule = TimeUnit.MINUTES.toMillis(start) < TimeUnit.MINUTES.toMillis(15); change makes sense. Did you try testing a fix with scheduling periodically instead prior to writing the custom implementation?

Hi, i didn't check with default scheduling periodically method. I'll check and confirm

allan-on
allan-on previously approved these changes Aug 22, 2022
@ekigamba
Copy link
Contributor

The branch cannot currently be merged with unverified commits in it's history and will require a re-write or force-merge

- This prevents blocking the EventClient method during registration as discovered by Owais
@ekigamba
Copy link
Contributor

@allan-on Kindly approve again. The difference is that I removed 2 unsigned commits by Owais. The following are the commits

commit 30a9915b1b5eec583012d4d17e25236ca55c2e36
Author: owais <syedowaisali@users.noreply.github.com>
Date:   Fri Jul 29 11:47:15 2022 +0500

    Revert "Merge branch 'master' into issue-2077"
    
    This reverts commit 7a9a6556d2432452d5ab7f1314be566994966774.

commit eaa979ed0185785818f5fc4e7e6c513f996ce26c
Author: owais <syedowaisali@users.noreply.github.com>
Date:   Fri Jul 29 15:24:49 2022 +0500

    trigger build

@ekigamba ekigamba requested a review from allan-on August 23, 2022 18:16
@hilpitome hilpitome merged commit 4c1701a into master Aug 24, 2022
@hilpitome hilpitome deleted the issue-2077 branch August 24, 2022 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Boresha Afya Fixes: Saving a Family takes more than 5mins
4 participants