From 3a73ea4fdc853bdf6d327318e8866107b1f3933e Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 24 Sep 2021 14:49:53 +0300 Subject: [PATCH 01/11] :construction: Update connection timeouts --- opensrp-chw/build.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index b6c1b539a9..3d09721991 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -293,8 +293,8 @@ android { togo { dimension = 'baseDimension' applicationIdSuffix ".togo" - versionCode 23 - versionName "1.2.5" + versionCode 24 + versionName "1.2.6" buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500' buildConfigField "String", 'opensrp_url', '"https://wcaro-tg.smartregister.org/opensrp/"' @@ -305,6 +305,8 @@ android { buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"National", "Regional" , "District" , "Formation sanitaire", "Supervisor", "Village"}' buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Village"' buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' + buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5' + buildConfigField "int", "MAX_READ_TIMEOUT", '5' buildConfigField "int", "DATABASE_VERSION", '20' } liberia { From 2c34e698f24a54062691d5a1ec2a264d569c6db6 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 24 Sep 2021 14:50:30 +0300 Subject: [PATCH 02/11] :construction: Reduce sync event batch-size --- .../java/org/smartregister/chw/sync/ChwSyncIntentService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java b/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java index 92b4535b25..4bcd215a1f 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java @@ -25,6 +25,6 @@ public int getEventPullLimit() { @Override protected Integer getEventBatchSize(){ - return 250; - } + return 180; + } // Should this be configurable? } From 4629cbd969da19123b0ed7e0ad63ab94de009d7e Mon Sep 17 00:00:00 2001 From: Allan O Date: Sun, 26 Sep 2021 23:07:04 +0300 Subject: [PATCH 03/11] :boom: Update OpenSRP end-point and app version --- opensrp-chw/build.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 6251b114d8..20421757fa 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -307,9 +307,9 @@ android { } liberia { dimension = 'baseDimension' - versionCode 6 - versionName "0.1.12" - buildConfigField "String", 'opensrp_url', '"https://wcaro-liberia.smartregister.org/opensrp/"' + versionCode 7 + versionName "0.2.0" + buildConfigField "String", 'opensrp_url', '"https://wcaro-lr.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/liberia/"' buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-lr-preview.smartregister.org/opensrp/"' buildConfigField "String[]", "LOCATION_HIERACHY", '{"Clinic" , "CHSS" , "CHA"}' @@ -317,6 +317,8 @@ android { buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Clinic" , "CHSS" , "CHA"}' buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"' + buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5' + buildConfigField "int", "MAX_READ_TIMEOUT", '5' buildConfigField "int", "DATABASE_VERSION", '7' } lmh { From 3707cedaf45bc34b77d3aecbc3f0aa4cc006d00b Mon Sep 17 00:00:00 2001 From: bitbucket <62241922+zzainulabidin@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:08:04 +0500 Subject: [PATCH 04/11] Update showChildrenUnderFiveAndGirlsAgeNineToEleven method --- .../org/smartregister/chw/application/ChwApplicationFlv.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opensrp-chw/src/togo/java/org/smartregister/chw/application/ChwApplicationFlv.java b/opensrp-chw/src/togo/java/org/smartregister/chw/application/ChwApplicationFlv.java index 538e82908e..7335e0204e 100644 --- a/opensrp-chw/src/togo/java/org/smartregister/chw/application/ChwApplicationFlv.java +++ b/opensrp-chw/src/togo/java/org/smartregister/chw/application/ChwApplicationFlv.java @@ -1,4 +1,8 @@ package org.smartregister.chw.application; public class ChwApplicationFlv extends DefaultChwApplicationFlv { + @Override + public boolean showChildrenUnderFiveAndGirlsAgeNineToEleven() { + return true; + } } From f3b46fa5baf8683f9140457d3cddfe61315de7d5 Mon Sep 17 00:00:00 2001 From: Allan O Date: Thu, 30 Sep 2021 17:33:07 +0300 Subject: [PATCH 05/11] :camera_flash: Update version to 1.0.0 There are major backwards incompatible changes incorporated --- opensrp-chw/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index e0d8862519..800b84b0bb 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -310,7 +310,7 @@ android { liberia { dimension = 'baseDimension' versionCode 7 - versionName "0.2.0" + versionName "1.0.0" buildConfigField "String", 'opensrp_url', '"https://wcaro-lr.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/liberia/"' buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-stage.smartregister.org/opensrp/"' From 16fd545f28c2f270bde12cf741d506fb1e09ad71 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 1 Oct 2021 14:16:02 +0300 Subject: [PATCH 06/11] :fire: Remove marking events with null ID as unsynced --- .../chw/sync/ChwSyncIntentService.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java b/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java index 92b4535b25..13ee30006b 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java @@ -1,22 +1,9 @@ package org.smartregister.chw.sync; -import org.smartregister.chw.dao.EventDao; import org.smartregister.sync.intent.SyncIntentService; public class ChwSyncIntentService extends SyncIntentService { - @Override - protected void handleSync() { - // fetch the last downloaded serverVersion before any unsyced data - Long serverVersion = EventDao.getMinimumVerifiedServerVersion(); - if (serverVersion != null) - org.smartregister.util.Utils.getAllSharedPreferences().saveLastSyncDate(serverVersion); - - // flag all contentious events as unsynced - EventDao.markEventsForReUpload(); - super.handleSync(); - } - @Override public int getEventPullLimit() { return 1000; From ecd7ae6a5bd84df3e318826f2b7e4c283e076ef2 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 1 Oct 2021 14:20:43 +0300 Subject: [PATCH 07/11] :card_file_box: Add missing event id for prior synced events The migration will add the event id from the event json if the event is valid --- .../chw/repository/ChwRepositoryFlv.java | 83 ++++++++++++++++--- 1 file changed, 71 insertions(+), 12 deletions(-) diff --git a/opensrp-chw/src/togo/java/org/smartregister/chw/repository/ChwRepositoryFlv.java b/opensrp-chw/src/togo/java/org/smartregister/chw/repository/ChwRepositoryFlv.java index d07ce1ce9f..7dcee515f0 100644 --- a/opensrp-chw/src/togo/java/org/smartregister/chw/repository/ChwRepositoryFlv.java +++ b/opensrp-chw/src/togo/java/org/smartregister/chw/repository/ChwRepositoryFlv.java @@ -1,10 +1,14 @@ package org.smartregister.chw.repository; +import static org.smartregister.repository.BaseRepository.TYPE_Synced; +import static org.smartregister.repository.BaseRepository.TYPE_Valid; + import android.content.Context; import android.database.Cursor; import net.sqlcipher.database.SQLiteDatabase; +import org.apache.commons.lang3.StringUtils; import org.joda.time.format.DateTimeFormat; import org.json.JSONObject; import org.smartregister.chw.anc.AncLibrary; @@ -51,6 +55,9 @@ public class ChwRepositoryFlv { + private static final String EVENT_ID = "id"; + private static final String _ID = "_id"; + public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion, int newVersion) { Timber.w(ChwRepository.class.getName(), "Upgrading database from version " + oldVersion + " to " @@ -109,6 +116,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion, case 20: upgradeToVersion20(db); break; + case 21: + upgradeToVersion21(db); + break; default: break; } @@ -116,14 +126,6 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion, } } - private static void upgradeToVersion20(SQLiteDatabase db) { - try { - db.execSQL("ALTER TABLE ec_family_member ADD COLUMN marital_status VARCHAR;"); - } catch (Exception e) { - Timber.e(e, "upgradeToVersion20"); - } - } - private static void upgradeToVersion2(Context context, SQLiteDatabase db) { try { db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_EVENT_ID_COL); @@ -336,6 +338,7 @@ private static List readEvents(Cursor cursor) { while (!cursor.isAfterLast()) { String json = cursor.getString(cursor.getColumnIndex("json")); Event event = syncHelper.convert(new JSONObject(json), Event.class); + event.setEventId(getEventId(json)); events.add(event); cursor.moveToNext(); } @@ -348,6 +351,24 @@ private static List readEvents(Cursor cursor) { return events; } + private static String getEventId(String jsonString) { + JSONObject jsonObject; + String eventId = null; + if (StringUtils.isNotEmpty(jsonString)) { + try { + jsonObject = new JSONObject(jsonString); + if (jsonObject.has(EVENT_ID)) { + eventId = jsonObject.getString(EVENT_ID); + }else if (jsonObject.has(_ID)) { + eventId = jsonObject.getString(_ID); + } + } catch (Exception ex) { + Timber.e(ex); + } + } + return eventId; + } + private static void processHFNextVisitDateObs(List events, SQLiteDatabase sqLiteDatabase) { // Save missing PNC Health Facility visit (next visit) details for (Event event : events) { @@ -420,17 +441,17 @@ private static void upgradeToVersion17(SQLiteDatabase db) { Timber.e(e, "upgradeToVersion17"); } } - + private static void upgradeToVersion18(SQLiteDatabase db) { try { ReportingLibrary reportingLibraryInstance = ReportingLibrary.getInstance(); initializeIndicatorDefinitions(reportingLibraryInstance, db); - } catch (Exception e){ + } catch (Exception e) { Timber.e(e, "upgradeToVersion18"); } } - - private static void upgradeToVersion19(Context context, SQLiteDatabase db) { + + private static void upgradeToVersion19(Context context, SQLiteDatabase db) { try { db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL); db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX); @@ -440,4 +461,42 @@ private static void upgradeToVersion19(Context context, SQLiteDatabase db) { Timber.e(e); } } + + private static void upgradeToVersion20(SQLiteDatabase db) { + try { + db.execSQL("ALTER TABLE ec_family_member ADD COLUMN marital_status VARCHAR;"); + } catch (Exception e) { + Timber.e(e, "upgradeToVersion20"); + } + } + + private static void upgradeToVersion21(SQLiteDatabase db) { + List events = new ArrayList<>(); + String eventTableName = EventClientRepository.Table.event.name(); + String eventIdCol = EventClientRepository.event_column.eventId.name(); + String eventSyncStatusCol = EventClientRepository.event_column.syncStatus.name(); + String eventValidCol = EventClientRepository.event_column.validationStatus.name(); + String jsonCol = EventClientRepository.event_column.json.name(); + String formSubmissionCol = EventClientRepository.event_column.formSubmissionId.name(); + + Cursor cursor; + String selection = eventIdCol + " IS NULL AND " + eventValidCol + " = ?"; + try { + cursor = db.query(eventTableName, new String[]{jsonCol}, + selection, new String[]{TYPE_Valid}, null, null, null); + events = readEvents(cursor); + } catch (Exception ex) { + Timber.e(ex); + } + String updateSQL; + for (Event event : events) { + updateSQL = String.format("UPDATE %s SET %s = '%s', %s = '%s' WHERE %s = '%s';", eventTableName, + eventIdCol, event.getEventId(), eventSyncStatusCol, TYPE_Synced, formSubmissionCol, event.getFormSubmissionId()); + try { + db.execSQL(updateSQL); + } catch (Exception e) { + Timber.e(e, "upgradeToVersion21 "); + } + } + } } From d7f47725a54b0ace0689decd2a263585d50fd9a4 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 1 Oct 2021 14:21:23 +0300 Subject: [PATCH 08/11] :camera_flash: Update Togo Snapshot and DB versions --- opensrp-chw/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 800b84b0bb..cf9be0ea7f 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -293,8 +293,8 @@ android { togo { dimension = 'baseDimension' applicationIdSuffix ".togo" - versionCode 23 - versionName "1.2.5" + versionCode 25 + versionName "1.2.7" buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500' buildConfigField "String", 'opensrp_url', '"https://wcaro-tg.smartregister.org/opensrp/"' @@ -305,7 +305,7 @@ android { buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"National", "Regional" , "District" , "Formation sanitaire", "Supervisor", "Village"}' buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Village"' buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' - buildConfigField "int", "DATABASE_VERSION", '20' + buildConfigField "int", "DATABASE_VERSION", '21' } liberia { dimension = 'baseDimension' From 04020336756ddef243c61f056ca972c32cb597b2 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 1 Oct 2021 14:53:08 +0300 Subject: [PATCH 09/11] :wrench: Update connection timeouts and event batch size --- opensrp-chw/build.gradle | 4 ++-- .../java/org/smartregister/chw/sync/ChwSyncIntentService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 75faa842fd..e9367397e8 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -305,8 +305,8 @@ android { buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"National", "Regional" , "District" , "Formation sanitaire", "Supervisor", "Village"}' buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Village"' buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' - buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '5' - buildConfigField "int", "MAX_READ_TIMEOUT", '5' + buildConfigField "int", "MAX_CONNECTION_TIMEOUT", '10' + buildConfigField "int", "MAX_READ_TIMEOUT", '10' buildConfigField "int", "DATABASE_VERSION", '21' } liberia { diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java b/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java index 923c1c4acb..efb9a9c2b5 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/sync/ChwSyncIntentService.java @@ -12,6 +12,6 @@ public int getEventPullLimit() { @Override protected Integer getEventBatchSize(){ - return 180; + return 50; } // Should this be configurable? } From d9aa41a6f49accd933d1bb01ab2019783fcf2c52 Mon Sep 17 00:00:00 2001 From: Allan O Date: Mon, 4 Oct 2021 12:41:09 +0300 Subject: [PATCH 10/11] :bug: Add missing charts lib --- opensrp-chw/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index e9367397e8..c176b62f40 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -382,6 +382,8 @@ dependencies { //For viewing PDFs in the app implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1' + implementation 'com.github.lecho:hellocharts-android:v1.5.8@aar' + testImplementation "org.koin:koin-test:2.0.1" testImplementation 'junit:junit:4.13' testImplementation 'org.mockito:mockito-core:3.1.0' From ec27d2e3705f820ff95ab5f5fcfd47e1497ce887 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 5 Oct 2021 11:42:58 +0300 Subject: [PATCH 11/11] :camera_flash: Update versionCode Update for new release --- opensrp-chw/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index c176b62f40..48162860a6 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -293,7 +293,7 @@ android { togo { dimension = 'baseDimension' applicationIdSuffix ".togo" - versionCode 25 + versionCode 26 versionName "1.2.7" buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500'