← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19495: Analytics, simplified code related to query planning and grouping by data type

 

------------------------------------------------------------
revno: 19495
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-06-23 00:31:16 +0200
message:
  Analytics, simplified code related to query planning and grouping by data type
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.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/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2015-06-18 21:47:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2015-06-22 22:31:16 +0000
@@ -265,27 +265,17 @@
                         List<DataQueryParams> groupedByAggregationType = groupByAggregationType( byDataType );
     
                         for ( DataQueryParams byAggregationType : groupedByAggregationType )
-                        {
-                            if ( byAggregationType.isDisaggregation() )
-                            {
-                                List<DataQueryParams> groupedByDataPeriodType = groupByDataPeriodType( byAggregationType );
-                                
-                                for ( DataQueryParams byDataPeriodType : groupedByDataPeriodType )
-                                {
-                                    byDataPeriodType.setPartitions( byPartition.getPartitions() );
-                                    byDataPeriodType.setPeriodType( byPeriodType.getPeriodType() );
-                                    byDataPeriodType.setAggregationType( byAggregationType.getAggregationType() );
-                                    
-                                    queries.add( byDataPeriodType );
-                                }
-                            }
-                            else
-                            {
-                                byAggregationType.setPartitions( byPartition.getPartitions() );
-                                byAggregationType.setPeriodType( byPeriodType.getPeriodType() );
-                                
-                                queries.add( byAggregationType );
-                            }
+                        {                            
+                            List<DataQueryParams> groupedByDataPeriodType = groupByDataPeriodType( byAggregationType );
+                            
+                            for ( DataQueryParams byDataPeriodType : groupedByDataPeriodType )
+                            {
+                                byDataPeriodType.setPartitions( byPartition.getPartitions() );
+                                byDataPeriodType.setPeriodType( byPeriodType.getPeriodType() );
+                                byDataPeriodType.setAggregationType( byAggregationType.getAggregationType() );
+                                
+                                queries.add( byDataPeriodType );
+                            } 
                         }
                     }
                 }
@@ -647,13 +637,14 @@
 
     /**
      * Groups the given query in sub queries based on the period type of its
-     * data elements. Sets the data period type on each query.
+     * data elements. Sets the data period type on each query. This only applies
+     * if the aggregation type of the query involves disaggregation.
      */
     private List<DataQueryParams> groupByDataPeriodType( DataQueryParams params )
     {
         List<DataQueryParams> queries = new ArrayList<>();
 
-        if ( params.getDataElements().isEmpty() )
+        if ( params.getDataElements().isEmpty() || !params.isDisaggregation() )
         {
             queries.add( params.instance() );
             return queries;