|
|
@ -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);
|
|
|
|