diff --git a/gradle.properties b/gradle.properties index c023046f..d272829a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.1.2-SNAPSHOT +VERSION_NAME=0.1.3-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Reporting Library diff --git a/opensrp-reporting/src/main/java/org/smartregister/reporting/dao/ReportIndicatorDaoImpl.java b/opensrp-reporting/src/main/java/org/smartregister/reporting/dao/ReportIndicatorDaoImpl.java index ec7694da..2217d76c 100644 --- a/opensrp-reporting/src/main/java/org/smartregister/reporting/dao/ReportIndicatorDaoImpl.java +++ b/opensrp-reporting/src/main/java/org/smartregister/reporting/dao/ReportIndicatorDaoImpl.java @@ -49,7 +49,7 @@ public class ReportIndicatorDaoImpl implements ReportIndicatorDao { public static final String REPORT_LAST_PROCESSED_DATE = "REPORT_LAST_PROCESSED_DATE"; public static String DAILY_TALLY_DATE_FORMAT = "yyyy-MM-dd"; - public static String PREVIOUS_REPORT_DATES_QUERY = "select distinct eventDate, " + EventClientRepository.event_column.updatedAt + " from " + public static String PREVIOUS_REPORT_DATES_QUERY = "select distinct eventDate, " + EventClientRepository.event_column.updatedAt +", "+ EventClientRepository.event_column.dateCreated + " from " + EventClientRepository.Table.event.name(); private static String eventDateFormat = "yyyy-MM-dd HH:mm:ss"; @@ -185,7 +185,12 @@ protected LinkedHashMap getReportEventDates(@NonNull Date timeNow, Date eventDate; Date updateDate; for (HashMap val : values) { - eventDate = formatDate(val.get(EventClientRepository.event_column.eventDate.name()), eventDateFormat); + String eventDateString = val.get(EventClientRepository.event_column.eventDate.name()); + if(eventDateString == null) + eventDateString = val.get(EventClientRepository.event_column.dateCreated.name()); + + + eventDate = formatDate(eventDateString, eventDateFormat); updateDate = formatDate(val.get(EventClientRepository.event_column.updatedAt.name()), eventDateFormat); String keyDate = new SimpleDateFormat(DAILY_TALLY_DATE_FORMAT, Locale.getDefault()).format(eventDate); diff --git a/opensrp-reporting/src/test/java/org/smartregister/reporting/dao/ReportIndicatorDaoImplTest.java b/opensrp-reporting/src/test/java/org/smartregister/reporting/dao/ReportIndicatorDaoImplTest.java index 81dcb9bb..df97e63f 100644 --- a/opensrp-reporting/src/test/java/org/smartregister/reporting/dao/ReportIndicatorDaoImplTest.java +++ b/opensrp-reporting/src/test/java/org/smartregister/reporting/dao/ReportIndicatorDaoImplTest.java @@ -97,6 +97,7 @@ public void executeQueryAndReturnCountShouldReturnCountFromQuery() { Assert.assertEquals(67F, actualResult, 0); } + @Test public void getReportEventDatesShouldReturnCurrentDateWhenNoDatesRetrievedFromEventTable() { Date timeNow = Calendar.getInstance().getTime(); SQLiteDatabase database = Mockito.mock(SQLiteDatabase.class); @@ -157,6 +158,7 @@ public void testGenerateDailyIndicatorTalliesCallsSaveTalliesEqualToNumberOfRepo @Test public void saveTalliesGeneratesTallyObject() { + SQLiteDatabase database = Mockito.mock(SQLiteDatabase.class); Map indicatorQueries = new HashMap<>(); Map.Entry dates = new Map.Entry() {