← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17920: Sharing, added max response limit to search. Makes the sharing user group search much more respon...

 

------------------------------------------------------------
revno: 17920
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-01-08 19:34:49 +0100
message:
  Sharing, added max response limit to search. Makes the sharing user group search much more responsive. No need for showing more than 20 hits since they will not be visible in UI.
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js


--
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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java	2014-11-14 13:19:13 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SharingController.java	2015-01-08 18:34:49 +0000
@@ -31,6 +31,7 @@
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -257,11 +258,21 @@
     }
 
     @RequestMapping( value = "/search", method = RequestMethod.GET, produces = { "application/json" } )
-    public void searchUserGroups( @RequestParam String key, HttpServletResponse response ) throws IOException
+    public void searchUserGroups( @RequestParam String key, @RequestParam Integer pageSize, HttpServletResponse response ) throws IOException
     {
+        if ( key == null )
+        {
+            ContextUtils.conflictResponse( response, "Search key not specified" );
+            return;
+        }
+        
+        int max = pageSize != null ? pageSize : Integer.MAX_VALUE;
+        
         SharingUserGroups sharingUserGroups = new SharingUserGroups();
 
-        for ( UserGroup userGroup : userGroupService.getUserGroupsBetweenByName( key, 0, Integer.MAX_VALUE ) )
+        List<UserGroup> userGroups = userGroupService.getUserGroupsBetweenByName( key, 0, max );
+        
+        for (  UserGroup userGroup : userGroups )
         {
             SharingUserGroupAccess sharingUserGroupAccess = new SharingUserGroupAccess();
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js	2015-01-07 09:17:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.sharing.js	2015-01-08 18:34:49 +0000
@@ -182,7 +182,7 @@
       modal: true,
       resizable: false,
       width: 485,
-      height: 500,
+      height: 555,
       buttons: {
         'Cancel': function() {
           $(this).dialog('destroy');
@@ -207,7 +207,8 @@
           url: '../api/sharing/search',
           dataType: 'json',
           data: {
-            key: request.term
+            key: request.term,
+            pageSize: 20
           }
         }).success(function( data ) {
           var v = [];