From 63489457fe0cc541eaf0cf2106f57817614b6789 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 22 May 2015 17:07:21 -0400 Subject: [PATCH] group search change --- src/groups.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/groups.js b/src/groups.js index 72cb0e9b28..02e24a41bb 100644 --- a/src/groups.js +++ b/src/groups.js @@ -1098,19 +1098,17 @@ var async = require('async'), Groups.search = function(query, options, callback) { if (!query) { - query = ''; + return callback(null, []); } - + query = query.toLowerCase(); async.waterfall([ async.apply(db.getObjectValues, 'groupslug:groupname'), function(groupNames, next) { groupNames = groupNames.filter(function(name) { - return name.match(new RegExp(query, 'i')) && name !== 'administrators'; + return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators'; }); - - async.mapLimit(groupNames, 5, function(groupName, next) { - Groups.get(groupName, options || {}, next); - }, next); + groupNames = groupNames.slice(0, 100); + Groups.getGroupsData(groupNames, next); }, async.apply(Groups.sort, options.sort) ], callback);