=== 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 groupedByAggregationType = groupByAggregationType( byDataType ); for ( DataQueryParams byAggregationType : groupedByAggregationType ) - { - if ( byAggregationType.isDisaggregation() ) - { - List 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 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 groupByDataPeriodType( DataQueryParams params ) { List queries = new ArrayList<>(); - if ( params.getDataElements().isEmpty() ) + if ( params.getDataElements().isEmpty() || !params.isDisaggregation() ) { queries.add( params.instance() ); return queries;