dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32824
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16720: Analytics, fixed bug, calculation of days in aggregation period was off with one day
------------------------------------------------------------
revno: 16720
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-09-14 21:39:53 +0200
message:
Analytics, fixed bug, calculation of days in aggregation period was off with one day
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-08-25 16:08:58 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-09-14 19:39:53 +0000
@@ -63,7 +63,6 @@
import static org.hisp.dhis.period.PeriodType.getPeriodTypeFromIsoString;
import static org.hisp.dhis.reporttable.ReportTable.IRT2D;
import static org.hisp.dhis.reporttable.ReportTable.addIfEmpty;
-import static org.hisp.dhis.system.util.DateUtils.daysBetween;
import java.util.ArrayList;
import java.util.Collection;
@@ -323,15 +322,13 @@
Period period = filterPeriod != null ? filterPeriod : (Period) DimensionItem.getPeriodItem( options );
- int days = daysBetween( period.getStartDate(), period.getEndDate() );
-
OrganisationUnit unit = (OrganisationUnit) DimensionItem.getOrganisationUnitItem( options );
String ou = unit != null ? unit.getUid() : null;
Map<String, Integer> orgUnitCountMap = permutationOrgUnitTargetMap != null ? permutationOrgUnitTargetMap.get( ou ) : null;
- Double value = expressionService.getIndicatorValue( indicator, period, valueMap, constantMap, orgUnitCountMap, days );
+ Double value = expressionService.getIndicatorValue( indicator, period, valueMap, constantMap, orgUnitCountMap, period.getDaysInPeriod() );
if ( value != null )
{
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java 2014-09-14 19:39:53 +0000
@@ -31,7 +31,9 @@
import static org.hisp.dhis.system.util.DateUtils.dateIsValid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import org.hisp.dhis.period.Cal;
import org.junit.Test;
/**
@@ -49,4 +51,10 @@
assertFalse( dateIsValid( "2000-03-40" ) );
assertFalse( dateIsValid( "20d20-03-01" ) );
}
+
+ @Test
+ public void testDaysBetween()
+ {
+ assertEquals( 6, DateUtils.daysBetween( new Cal( 2014, 3, 1 ).time(), new Cal( 2014, 3, 7 ).time() ) );
+ }
}