← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15182: Event analytics, fixed bug, total number of records in pager was wrong on multi-partition queries

 

------------------------------------------------------------
revno: 15182
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-06 17:50:09 +0200
message:
  Event analytics, fixed bug, total number of records in pager was wrong on multi-partition queries
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.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/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-04-21 14:52:46 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-05-06 15:50:09 +0000
@@ -269,7 +269,14 @@
     {
         String sql = "select count(psi) ";
         
-        sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
+        if ( params.spansMultiplePartitions() )
+        {
+            sql += getFromWhereMultiplePartitionsClause( params, Arrays.asList( "psi" ) );
+        }
+        else
+        {
+            sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
+        }
         
         int count = 0;
         
@@ -325,13 +332,11 @@
 
     private String getFromWhereMultiplePartitionsClause( EventQueryParams params, List<String> fixedColumns )
     {
-        String fixedCols = getSelectString( fixedColumns );
-        
         String sql = "from (";
         
         for ( String partition : params.getPartitions().getPartitions() )
         {
-            sql += "select " + fixedCols + getSelectColumns( params );
+            sql += "select " + getSelectString( fixedColumns ) + getSelectColumns( params );
             
             sql += " " + getFromWhereClause( params, partition );
             
@@ -441,6 +446,11 @@
      */
     private String getSelectString( List<String> columns )
     {
+        if ( columns == null || columns.isEmpty() )
+        {
+            return "";
+        }
+        
         String fixedCols = StringUtils.join( columns, ", " );
         
         return StringUtils.defaultIfEmpty( fixedCols + ", ", fixedCols );