From 8aac4bdfa10bfbc9684f02b8608d002bc58b32bc Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 19 May 2015 00:06:37 -0400 Subject: [PATCH] fixed issue where Groups.getUserGroups called getGroupsData on all groups, resulting in a very unscalable method if called on forum with thousands of groups --- src/groups.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/groups.js b/src/groups.js index 6cff59ded0..b46b23aca5 100644 --- a/src/groups.js +++ b/src/groups.js @@ -981,13 +981,13 @@ var async = require('async'), return groupName !== 'registered-users' && groupName.indexOf(':privileges:') === -1; }); - Groups.getGroupsData(groupNames, function(err, groupData) { + Groups.getMultipleGroupFields(groupNames, ['name', 'hidden'], function(err, groupData) { if (err) { return callback(err); } groupData = groupData.filter(function(group) { - return group && !group.hidden; + return group && !parseInt(group.hidden, 10); }); var groupSets = groupData.map(function(group) { @@ -1003,11 +1003,11 @@ var async = require('async'), var memberOf = []; isMembers.forEach(function(isMember, index) { if (isMember) { - memberOf.push(groupData[index]); + memberOf.push(groupData[index].name); } }); - next(null, memberOf); + Groups.getGroupsData(memberOf, next); }); }, callback); });