mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
* remove some unused dependencies * update mongoose version * make common tests pass * Make unit tests pass * make api v3 integration tests pass * fix lint issues * fix issue with package-lock * fix(lint): we don't need no .js * fix(lint): update to latest config-habitrpg * chore(npm): update package locks * fix(test): replace deprecated fn * chore(package): update eslint-habitrpg again * fix(lint): server linting * fix(lint): client linting * fix(client): correct mangled common imports * chore(npm): update package-locks * fix(lint): punctuation, module --------- Co-authored-by: SabreCat <sabrecat@gmail.com> Co-authored-by: SabreCat <sabe@habitica.com>
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
/* let migrationName = 'Jackalopes for Unlimited Subscribers'; */
|
|
|
|
/*
|
|
* This migration will find users with unlimited subscriptions who are also eligible
|
|
* for Jackalope mounts, and award them
|
|
*/
|
|
|
|
import { model as Group } from '../../website/server/models/group';
|
|
import { model as User } from '../../website/server/models/user';
|
|
|
|
async function handOutJackalopes () {
|
|
const promises = [];
|
|
const cursor = User.find({
|
|
'purchased.plan.customerId': 'habitrpg',
|
|
}).cursor();
|
|
|
|
cursor.on('data', async user => {
|
|
console.log(`User: ${user._id}`);
|
|
|
|
let groupList = [];
|
|
if (user.party._id) groupList.push(user.party._id);
|
|
groupList = groupList.concat(user.guilds);
|
|
|
|
const subscribedGroup = await Group.findOne(
|
|
{
|
|
_id: { $in: groupList },
|
|
'purchased.plan.planId': 'group_monthly',
|
|
'purchased.plan.dateTerminated': null,
|
|
},
|
|
{ _id: 1 },
|
|
);
|
|
|
|
if (subscribedGroup) {
|
|
User.update({ _id: user._id }, { $set: { 'items.mounts.Jackalope-RoyalPurple': true } }).exec();
|
|
promises.push(user.save());
|
|
}
|
|
});
|
|
|
|
cursor.on('close', async () => {
|
|
console.log('done');
|
|
return Promise.all(promises);
|
|
});
|
|
}
|
|
|
|
export default handOutJackalopes;
|