From 6f1b5fad7f13be6ca178184d452ddd840b5df2c1 Mon Sep 17 00:00:00 2001 From: Simon Njoroge Date: Mon, 19 Sep 2022 11:18:36 +0300 Subject: [PATCH] Move sync batch size settings to SyncConfiguration - Bump up version --- gradle.properties | 2 +- .../org/smartregister/SyncConfiguration.java | 32 +++++++++++++++++-- .../sync/intent/SyncIntentService.java | 6 ++-- .../sync/intent/ValidateIntentService.java | 3 +- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index cfb2ff9d7..8fa0c3819 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=5.0.6-SNAPSHOT +VERSION_NAME=5.0.7-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Core Application diff --git a/opensrp-core/src/main/java/org/smartregister/SyncConfiguration.java b/opensrp-core/src/main/java/org/smartregister/SyncConfiguration.java index be692df8e..eeff1eef0 100644 --- a/opensrp-core/src/main/java/org/smartregister/SyncConfiguration.java +++ b/opensrp-core/src/main/java/org/smartregister/SyncConfiguration.java @@ -227,13 +227,41 @@ public boolean validateUserAssignments() { return true; } - /** * Specifies whether to skip locally saved task marked as {@link org.smartregister.repository.BaseRepository#TYPE_Unsynced} * when fetching tasks from the server, during sync + * * @return {@link Boolean} */ - public boolean skipUnsyncedTasksOnFetchFromServer(){ + public boolean skipUnsyncedTasksOnFetchFromServer() { return false; } + + /** + * Specifies the batch size of clients and events to be pulled from the server in a single request + * + * @return {@link Integer} + */ + public int getSyncPullBatchSize() { + return 250; + } + + /** + * Specifies the batch size of clients and events to be pushed to the server in a single request + * + * @return {@link Integer} + */ + public int getSyncPushBatchSize() { + return 50; + } + + /** + * Specifies the batch size of clients and event IDs that + * are sent to server for validation in a single request + * + * @return {@link Integer} + */ + public int getSyncValidationBatchSize() { + return 100; + } } diff --git a/opensrp-core/src/main/java/org/smartregister/sync/intent/SyncIntentService.java b/opensrp-core/src/main/java/org/smartregister/sync/intent/SyncIntentService.java index fde67dd40..f13977a39 100644 --- a/opensrp-core/src/main/java/org/smartregister/sync/intent/SyncIntentService.java +++ b/opensrp-core/src/main/java/org/smartregister/sync/intent/SyncIntentService.java @@ -59,8 +59,6 @@ public class SyncIntentService extends BaseSyncIntentService { public static final String SYNC_URL = "/rest/event/sync"; - protected static final int EVENT_PULL_LIMIT = 250; - protected static final int EVENT_PUSH_LIMIT = 50; private static final String ADD_URL = "rest/event/add"; private static final String FAILED_CLIENTS = "failed_clients"; private static final String FAILED_EVENTS = "failed_events"; @@ -511,7 +509,7 @@ protected void sendSyncProgressBroadcast(int eventCount) { } public int getEventPullLimit() { - return EVENT_PULL_LIMIT; + return CoreLibrary.getInstance().getSyncConfiguration().getSyncPullBatchSize(); } public HTTPAgent getHttpAgent() { @@ -533,6 +531,6 @@ protected String getFormattedBaseUrl() { } protected Integer getEventBatchSize() { - return EVENT_PUSH_LIMIT; + return CoreLibrary.getInstance().getSyncConfiguration().getSyncPushBatchSize(); } } diff --git a/opensrp-core/src/main/java/org/smartregister/sync/intent/ValidateIntentService.java b/opensrp-core/src/main/java/org/smartregister/sync/intent/ValidateIntentService.java index a91dafa15..111424e11 100644 --- a/opensrp-core/src/main/java/org/smartregister/sync/intent/ValidateIntentService.java +++ b/opensrp-core/src/main/java/org/smartregister/sync/intent/ValidateIntentService.java @@ -32,7 +32,6 @@ public class ValidateIntentService extends BaseSyncIntentService { private Context context; private HTTPAgent httpAgent; - private static final int FETCH_LIMIT = 100; private static final String VALIDATE_SYNC_PATH = "rest/validate/sync"; private org.smartregister.Context openSRPContext = CoreLibrary.getInstance().context(); @@ -54,7 +53,7 @@ protected void onHandleIntent(Intent intent) { try { super.onHandleIntent(intent); - int fetchLimit = FETCH_LIMIT; + int fetchLimit = CoreLibrary.getInstance().getSyncConfiguration().getSyncValidationBatchSize(); List clientIds = eventClientRepository.getUnValidatedClientBaseEntityIds(fetchLimit); if (!clientIds.isEmpty()) {