From 50d9a3f0a7a71f0e8631b8d7e512696d65e54278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 26 May 2015 13:44:52 -0400 Subject: [PATCH] dont call groups.get just to read 2 values --- src/groups.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/groups.js b/src/groups.js index 7763353764..e6acafcd80 100644 --- a/src/groups.js +++ b/src/groups.js @@ -647,13 +647,12 @@ var async = require('async'), uid: uid }); - // If this is a hidden group, and it is now empty, delete it - Groups.get(groupName, {}, function(err, group) { - if (err || !group) { + Groups.getGroupFields(groupName, ['hidden', 'memberCount'], function(err, groupData) { + if (err || !groupData) { return callback(err); } - if (group.hidden && group.memberCount === 0) { + if (parseInt(groupData.hidden, 10) === 1 && parseInt(groupData.memberCount, 10) === 0) { Groups.destroy(groupName, callback); } else { callback();