group search change

v1.18.x
barisusakli 10 years ago
parent 1c4d78eb2d
commit 63489457fe

@ -1098,19 +1098,17 @@ var async = require('async'),
Groups.search = function(query, options, callback) { Groups.search = function(query, options, callback) {
if (!query) { if (!query) {
query = ''; return callback(null, []);
} }
query = query.toLowerCase();
async.waterfall([ async.waterfall([
async.apply(db.getObjectValues, 'groupslug:groupname'), async.apply(db.getObjectValues, 'groupslug:groupname'),
function(groupNames, next) { function(groupNames, next) {
groupNames = groupNames.filter(function(name) { groupNames = groupNames.filter(function(name) {
return name.match(new RegExp(query, 'i')) && name !== 'administrators'; return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators';
}); });
groupNames = groupNames.slice(0, 100);
async.mapLimit(groupNames, 5, function(groupName, next) { Groups.getGroupsData(groupNames, next);
Groups.get(groupName, options || {}, next);
}, next);
}, },
async.apply(Groups.sort, options.sort) async.apply(Groups.sort, options.sort)
], callback); ], callback);

Loading…
Cancel
Save