Better group plan member counts (#10449)

* fix(group-plans): improved member count accuracy

* fix(migration): don't leave server running after completion

* fix(migration): don't update Stripe for non-Stripe methods
Also fixes a linting issue.

* fix(lint): no comma dangle here

* fix(async): put async token in relevant spot

* fix(lint): still more linting

* fix(async): better handling for async and promises
Also adds additional logging where discrepancies are found.

* feat(migration): provide CSV output

* fix(promises): better pause/resume

* fix(migration): don't update already canceled subs

* fix(groups): also address quantity/memberCount discrepancies

* fix(migration): also log quantity issues

* fix(migration): equation was reversed

* refactor(migration): condense logic, add error catch

* fix(migration): fix root cause of failed quantity update??

* fix(lint): gratuitous parens

* fix(test): expect group to be updated db-side

* fix(migration): actually update quantities?

* fix(groups): roll back unneeded Stripe lib change, refactor migration
This commit is contained in:
Sabe Jones
2018-06-15 14:49:18 -05:00
committed by GitHub
parent 6a767ed70b
commit 7ea6c911cb
4 changed files with 111 additions and 2 deletions
@@ -196,6 +196,7 @@ api.createGroupPlan = {
// @TODO: Change message
if (group.privacy !== 'private') throw new NotAuthorized(res.t('partyMustbePrivate'));
group.memberCount = await User.count({ $or: [{ 'party._id': group._id }, { guilds: group._id }] }).exec();
group.leader = user._id;
user.guilds.push(group._id);