diff --git a/.travis.yml b/.travis.yml
index 1ebe4d21..05733cb5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,14 +14,6 @@ cache:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
-env:
- matrix:
- - ANDROID_TARGET=android-22 ANDROID_ABI=armeabi-v7a
- global:
- # wait up to 10 minutes for adb to connect to emulator
- - MALLOC_ARENA_MAX=2
- - ADB_INSTALL_TIMEOUT=20 #increment timeout to 20 mins
-
android:
components:
# tools required
@@ -35,17 +27,6 @@ android:
- extra-google-m2repository
- extra-android-m2repository
- # Specify at least one system image,
- # if you need to run emulator(s) during your tests
- - sys-img-armeabi-v7a-android-22
-
-before_script:
- # Emulator Management: Create, Start and Wait
- - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- - emulator -avd test -no-skin -no-audio -no-window &
- - android-wait-for-emulator
- - adb shell input keyevent 82 &
-
script:
- echo "Travis branch is $TRAVIS_BRANCH"
- echo "Travis branch is in pull request $TRAVIS_PULL+REQUEST"
diff --git a/gradle.properties b/gradle.properties
index 540e6375..114fb136 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-VERSION_NAME=0.0.8-SNAPSHOT
+VERSION_NAME=0.0.9-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Reporting Library
diff --git a/opensrp-reporting/src/androidTest/java/org/smartregister/reporting/ExampleInstrumentedTest.java b/opensrp-reporting/src/androidTest/java/org/smartregister/reporting/ExampleInstrumentedTest.java
deleted file mode 100644
index 17c995de..00000000
--- a/opensrp-reporting/src/androidTest/java/org/smartregister/reporting/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.smartregister.reporting;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("org.smartregister.reporting", appContext.getPackageName());
- }
-}
diff --git a/opensrp-reporting/src/main/java/org/smartregister/reporting/ReportingLibrary.java b/opensrp-reporting/src/main/java/org/smartregister/reporting/ReportingLibrary.java
index 0d8b6a77..66a931af 100644
--- a/opensrp-reporting/src/main/java/org/smartregister/reporting/ReportingLibrary.java
+++ b/opensrp-reporting/src/main/java/org/smartregister/reporting/ReportingLibrary.java
@@ -226,9 +226,11 @@ public void readConfigFile(String configFilePath, SQLiteDatabase sqLiteDatabase)
indicatorQuery = new IndicatorQuery(null, indicatorYamlConfigItem.getKey()
, indicatorYamlConfigItem.getIndicatorQuery()
, 0
- , indicatorYamlConfigItem.isMultiResult());
+ , indicatorYamlConfigItem.isMultiResult()
+ , indicatorYamlConfigItem.getExpectedIndicators());
indicatorQueries.add(indicatorQuery);
}
+
reportIndicators.add(indicator);
}
}
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 cb544c20..7229bdb6 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
@@ -2,6 +2,8 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
import com.google.gson.Gson;
@@ -16,12 +18,12 @@
import org.smartregister.reporting.repository.DailyIndicatorCountRepository;
import org.smartregister.reporting.repository.IndicatorQueryRepository;
import org.smartregister.reporting.repository.IndicatorRepository;
-import org.smartregister.reporting.util.AppProperties;
import org.smartregister.repository.EventClientRepository;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -39,12 +41,12 @@
*/
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 "
+ EventClientRepository.Table.event.name();
- private static String TAG = ReportIndicatorDaoImpl.class.getCanonicalName();
private static String eventDateFormat = "yyyy-MM-dd HH:mm:ss";
private IndicatorQueryRepository indicatorQueryRepository;
private DailyIndicatorCountRepository dailyIndicatorCountRepository;
@@ -80,13 +82,19 @@ public void generateDailyIndicatorTallies(String lastProcessedDate) {
float count;
SQLiteDatabase database = ReportingLibrary.getInstance().getRepository().getWritableDatabase();
- LinkedHashMap reportEventDates = getReportEventDates(lastProcessedDate, database);
+ Date timeNow = Calendar.getInstance().getTime();
+ LinkedHashMap reportEventDates = getReportEventDates(timeNow, lastProcessedDate, database);
+
Map indicatorQueries = indicatorQueryRepository.getAllIndicatorQueries();
if (!reportEventDates.isEmpty() && !indicatorQueries.isEmpty()) {
- String lastUpdatedDate = "";
+ String lastUpdatedDate = null;
+
for (Map.Entry dates : reportEventDates.entrySet()) {
- lastUpdatedDate = new SimpleDateFormat(eventDateFormat, Locale.getDefault()).format(dates.getValue());
+ if (dates.getValue().getTime() != timeNow.getTime()) {
+ lastUpdatedDate = new SimpleDateFormat(eventDateFormat, Locale.getDefault()).format(dates.getValue());
+ }
+
for (Map.Entry entry : indicatorQueries.entrySet()) {
IndicatorQuery indicatorQuery = entry.getValue();
CompositeIndicatorTally tally = null;
@@ -95,10 +103,11 @@ public void generateDailyIndicatorTallies(String lastProcessedDate) {
ArrayList