From ac09b90016a8e5e7aa896e662b416e3e2cd7cdfd Mon Sep 17 00:00:00 2001 From: Allan O Date: Thu, 24 Oct 2019 15:50:17 +0300 Subject: [PATCH 1/2] Refactor getLatestVisit to use a supplied SQliteDatabase instance --- opensrp-chw-anc/gradle.properties | 2 +- .../chw/anc/repository/VisitRepository.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-anc/gradle.properties b/opensrp-chw-anc/gradle.properties index 11e943bd..3001a1b8 100644 --- a/opensrp-chw-anc/gradle.properties +++ b/opensrp-chw-anc/gradle.properties @@ -1,5 +1,5 @@ POM_SETTING_NAME=OpenSRP Client Chw Anc POM_SETTING_ARTIFACT_ID=opensrp-client-chw-anc POM_SETTING_PACKAGING=aar -VERSION_NAME=0.1.31-SNAPSHOT +VERSION_NAME=0.1.32-SNAPSHOT VERSION_CODE=1 \ No newline at end of file diff --git a/opensrp-chw-anc/src/main/java/org/smartregister/chw/anc/repository/VisitRepository.java b/opensrp-chw-anc/src/main/java/org/smartregister/chw/anc/repository/VisitRepository.java index 06dab0c9..d15a951f 100644 --- a/opensrp-chw-anc/src/main/java/org/smartregister/chw/anc/repository/VisitRepository.java +++ b/opensrp-chw-anc/src/main/java/org/smartregister/chw/anc/repository/VisitRepository.java @@ -297,10 +297,17 @@ public Visit getVisitByFormSubmissionID(String formSubmissionID) { } public Visit getLatestVisit(String baseEntityID, String visitType) { + return getLatestVisit(baseEntityID, visitType, null); + } + + public Visit getLatestVisit(String baseEntityID, String visitType, SQLiteDatabase sqLiteDatabase) { + if (sqLiteDatabase == null) { + sqLiteDatabase = getReadableDatabase(); + } List visits = new ArrayList<>(); Cursor cursor = null; try { - cursor = getReadableDatabase().query(VISIT_TABLE, VISIT_COLUMNS, BASE_ENTITY_ID + " = ? AND " + VISIT_TYPE + " = ? ", new String[]{baseEntityID, visitType}, null, null, VISIT_DATE + " DESC ", "1"); + cursor = sqLiteDatabase.query(VISIT_TABLE, VISIT_COLUMNS, BASE_ENTITY_ID + " = ? AND " + VISIT_TYPE + " = ? ", new String[]{baseEntityID, visitType}, null, null, VISIT_DATE + " DESC ", "1"); visits = readVisits(cursor); } catch (Exception e) { Timber.e(e); From 64121eee4dd61ac98cb11e903deca03234340c49 Mon Sep 17 00:00:00 2001 From: Allan O Date: Fri, 25 Oct 2019 12:00:11 +0300 Subject: [PATCH 2/2] Increase general library snapshot version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7703ceb0..66bc4254 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.1.19-SNAPSHOT +VERSION_NAME=0.1.20-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client CHW Anc Library