← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19386: Event analytics, centralized code

 

------------------------------------------------------------
revno: 19386
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-06-13 19:18:42 +0200
message:
  Event analytics, centralized code
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	2015-06-13 15:10:41 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-06-13 17:18:42 +0000
@@ -103,14 +103,7 @@
         // Criteria
         // ---------------------------------------------------------------------
 
-        if ( params.spansMultiplePartitions() )
-        {
-            sql += getFromWhereMultiplePartitionsClause( params, Arrays.asList( "psi" ) );
-        }
-        else
-        {
-            sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
-        }
+        sql += getFromWhereClause( params, Arrays.asList( "psi" ) );
 
         // ---------------------------------------------------------------------
         // Group by
@@ -203,14 +196,7 @@
         // Criteria
         // ---------------------------------------------------------------------
 
-        if ( params.spansMultiplePartitions() )
-        {
-            sql += getFromWhereMultiplePartitionsClause( params, fixedCols );
-        }
-        else
-        {
-            sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
-        }
+        sql += getFromWhereClause( params, fixedCols );
         
         // ---------------------------------------------------------------------
         // Sorting
@@ -288,15 +274,8 @@
     {
         String sql = "select count(psi) ";
         
-        if ( params.spansMultiplePartitions() )
-        {
-            sql += getFromWhereMultiplePartitionsClause( params, Arrays.asList( "psi" ) );
-        }
-        else
-        {
-            sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
-        }
-        
+        sql += getFromWhereClause( params, Arrays.asList( "psi" ) );
+                
         int count = 0;
         
         try
@@ -402,6 +381,18 @@
         return removeLastComma( sql );
     }
 
+    private String getFromWhereClause( EventQueryParams params, List<String> fixedColumns )
+    {
+        if ( params.spansMultiplePartitions() )
+        {
+            return getFromWhereMultiplePartitionsClause( params, fixedColumns );
+        }
+        else
+        {
+            return getFromWhereSinglePartitionClause( params, params.getPartitions().getSinglePartition() );
+        }
+    }
+    
     private String getFromWhereMultiplePartitionsClause( EventQueryParams params, List<String> fixedColumns )
     {
         String sql = "from (";
@@ -410,7 +401,7 @@
         {
             sql += "select " + getSelectString( fixedColumns ) + getSelectColumns( params );
             
-            sql += " " + getFromWhereClause( params, partition );
+            sql += " " + getFromWhereSinglePartitionClause( params, partition );
             
             sql += "union all ";
         }
@@ -420,7 +411,7 @@
         return sql;
     }
     
-    private String getFromWhereClause( EventQueryParams params, String partition )
+    private String getFromWhereSinglePartitionClause( EventQueryParams params, String partition )
     {
         String sql = "from " + partition + " ";