← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15183: Event analytics, fixed bug, sorting and limit for queries spanning multiple partitions

 

------------------------------------------------------------
revno: 15183
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-06 18:30:43 +0200
message:
  Event analytics, fixed bug, sorting and limit for queries spanning multiple partitions
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.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/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2014-04-21 14:52:46 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2014-05-06 16:30:43 +0000
@@ -240,6 +240,15 @@
         return limit != null && limit > 0;
     }
     
+    /**
+     * Returns a negative integer in case of ascending sort order, a positive in
+     * case of descending sort order and 0 in case of no sort order.
+     */
+    public int getSortOrderAsInt()
+    {
+        return SortOrder.ASC.equals( sortOrder ) ? -1 : SortOrder.DESC.equals( sortOrder ) ? 1 : 0;
+    }
+    
     public String toString()
     {
         return "[" +

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-04-28 18:23:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-05-06 16:30:43 +0000
@@ -169,6 +169,20 @@
         {
             throw new IllegalQueryException( "Number of rows produced by query is larger than the max limit: " + MAX_ROWS_LIMIT );
         }
+
+        // ---------------------------------------------------------------------
+        // Limit and sort - done again due to potential multiple partitions
+        // ---------------------------------------------------------------------
+        
+        if ( params.hasLimit() && grid.getHeight() > params.getLimit() )
+        {
+            grid.limitGrid( params.getLimit() );
+        }
+        
+        if ( params.hasSortOrder() )
+        {            
+            grid.sortGrid( 1, params.getSortOrderAsInt() );
+        }
         
         // ---------------------------------------------------------------------
         // Meta-data