mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
added 2022 birthday bash robes & updated migration script
This commit is contained in:
Submodule habitica-images updated: 4ab9833a58...9e8d821858
97
migrations/archive/2022/20210129_habit_birthday.js
Normal file
97
migrations/archive/2022/20210129_habit_birthday.js
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
const MIGRATION_NAME = '20220131_habit_birthday';
|
||||||
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
|
import { model as User } from '../../../website/server/models/user';
|
||||||
|
|
||||||
|
const progressCount = 1000;
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
async function updateUser (user) {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
const inc = {
|
||||||
|
'items.food.Cake_Skeleton': 1,
|
||||||
|
'items.food.Cake_Base': 1,
|
||||||
|
'items.food.Cake_CottonCandyBlue': 1,
|
||||||
|
'items.food.Cake_CottonCandyPink': 1,
|
||||||
|
'items.food.Cake_Shade': 1,
|
||||||
|
'items.food.Cake_White': 1,
|
||||||
|
'items.food.Cake_Golden': 1,
|
||||||
|
'items.food.Cake_Zombie': 1,
|
||||||
|
'items.food.Cake_Desert': 1,
|
||||||
|
'items.food.Cake_Red': 1,
|
||||||
|
'achievements.habitBirthdays': 1,
|
||||||
|
};
|
||||||
|
const set = {};
|
||||||
|
let push;
|
||||||
|
|
||||||
|
set.migration = MIGRATION_NAME;
|
||||||
|
|
||||||
|
if (typeof user.items.gear.owned.armor_special_birthday2021 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2022'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2022', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday2020 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2021'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2021', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday2019 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2020'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2020', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday2018 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2019'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2019', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday2017 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2018'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2018', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday2016 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2017'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2017', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday2015 !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2016'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2016', _id: uuid()}};
|
||||||
|
} else if (typeof user.items.gear.owned.armor_special_birthday !== 'undefined') {
|
||||||
|
set['items.gear.owned.armor_special_birthday2015'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday2015', _id: uuid()}};
|
||||||
|
} else {
|
||||||
|
set['items.gear.owned.armor_special_birthday'] = false;
|
||||||
|
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_birthday', _id: uuid()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||||
|
|
||||||
|
return await User.update({_id: user._id}, {$inc: inc, $set: set, $push: push}).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function processUsers () {
|
||||||
|
let query = {
|
||||||
|
// migration: {$ne: MIGRATION_NAME},
|
||||||
|
'auth.timestamps.loggedin': {$gt: new Date('2022-01-01')},
|
||||||
|
};
|
||||||
|
|
||||||
|
const fields = {
|
||||||
|
_id: 1,
|
||||||
|
items: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
while (true) { // eslint-disable-line no-constant-condition
|
||||||
|
const users = await User // eslint-disable-line no-await-in-loop
|
||||||
|
.find(query)
|
||||||
|
.limit(250)
|
||||||
|
.sort({_id: 1})
|
||||||
|
.select(fields)
|
||||||
|
.lean()
|
||||||
|
.exec();
|
||||||
|
|
||||||
|
if (users.length === 0) {
|
||||||
|
console.warn('All appropriate users found and modified.');
|
||||||
|
console.warn(`\n${count} users processed\n`);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
query._id = {
|
||||||
|
$gt: users[users.length - 1],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(users.map(updateUser)); // eslint-disable-line no-await-in-loop
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -729,6 +729,9 @@
|
|||||||
"armorSpecialBirthday2020Notes": "Happy Birthday, Habitica! Wear these Outrageous Party Robes to celebrate this wonderful day. Confers no benefit.",
|
"armorSpecialBirthday2020Notes": "Happy Birthday, Habitica! Wear these Outrageous Party Robes to celebrate this wonderful day. Confers no benefit.",
|
||||||
"armorSpecialBirthday2021Text": "Extravagant Party Robes",
|
"armorSpecialBirthday2021Text": "Extravagant Party Robes",
|
||||||
"armorSpecialBirthday2021Notes": "Happy Birthday, Habitica! Wear these Extravagant Party Robes to celebrate this wonderful day. Confers no benefit.",
|
"armorSpecialBirthday2021Notes": "Happy Birthday, Habitica! Wear these Extravagant Party Robes to celebrate this wonderful day. Confers no benefit.",
|
||||||
|
"armorSpecialBirthday2022Text": "Preposterous Party Robes",
|
||||||
|
"armorSpecialBirthday2022Notes": "Happy Birthday, Habitica! Wear these Proposterous Party Robes to celebrate this wonderful day. Confers no benefit.",
|
||||||
|
|
||||||
|
|
||||||
"armorSpecialGaymerxText": "Rainbow Warrior Armor",
|
"armorSpecialGaymerxText": "Rainbow Warrior Armor",
|
||||||
"armorSpecialGaymerxNotes": "In celebration of the GaymerX Conference, this special armor is decorated with a radiant, colorful rainbow pattern! GaymerX is a game convention celebrating LGTBQ and gaming and is open to everyone.",
|
"armorSpecialGaymerxNotes": "In celebration of the GaymerX Conference, this special armor is decorated with a radiant, colorful rainbow pattern! GaymerX is a game convention celebrating LGTBQ and gaming and is open to everyone.",
|
||||||
|
|||||||
@@ -716,6 +716,12 @@ const armor = {
|
|||||||
winter2022Healer: {
|
winter2022Healer: {
|
||||||
set: 'winter2022IceCrystalHealerSet',
|
set: 'winter2022IceCrystalHealerSet',
|
||||||
},
|
},
|
||||||
|
birthday2022: {
|
||||||
|
text: t('armorSpecialBirthday2022Text'),
|
||||||
|
notes: t('armorSpecialBirthday2022Notes'),
|
||||||
|
value: 0,
|
||||||
|
canOwn: ownsItem('armor_special_birthday2022'),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const armorStats = {
|
const armorStats = {
|
||||||
|
|||||||
Reference in New Issue
Block a user