Skip to content

Commit

Permalink
Merge pull request #120 from opensrp/fix-eventDate-null-support
Browse files Browse the repository at this point in the history
Fix event date null support
  • Loading branch information
dubdabasoduba authored Oct 18, 2021
2 parents 3d7032f + 04a411d commit 887df19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -185,7 +185,12 @@ protected LinkedHashMap<String, Date> getReportEventDates(@NonNull Date timeNow,
Date eventDate;
Date updateDate;
for (HashMap<String, String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -157,6 +158,7 @@ public void testGenerateDailyIndicatorTalliesCallsSaveTalliesEqualToNumberOfRepo
@Test
public void saveTalliesGeneratesTallyObject() {


SQLiteDatabase database = Mockito.mock(SQLiteDatabase.class);
Map<String, IndicatorQuery> indicatorQueries = new HashMap<>();
Map.Entry<String, Date> dates = new Map.Entry<String, Date>() {
Expand Down

0 comments on commit 887df19

Please sign in to comment.