Veteran Pet ladder award for users affected by username changes (#10765)

* feat(usernames): Veteran Pet ladder award for affected users

* feat(content): Vet Pet Bailey etc.
This commit is contained in:
Sabe Jones
2018-10-23 17:38:30 -05:00
committed by GitHub
parent ff57e31f4f
commit 2fc1f46359
13 changed files with 147 additions and 37 deletions

View File

@@ -0,0 +1,93 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '20181023_veteran_pet_ladder';
import { model as User } from '../../website/server/models/user';
function processUsers (lastId) {
let query = {
migration: {$ne: MIGRATION_NAME},
'flags.verifiedUsername': true,
};
let fields = {
'items.pets': 1,
};
if (lastId) {
query._id = {
$gt: lastId,
};
}
return User.find(query)
.limit(250)
.sort({_id: 1})
.select(fields)
.then(updateUsers)
.catch((err) => {
console.log(err);
return exiting(1, `ERROR! ${err}`);
});
}
let progressCount = 1000;
let count = 0;
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}
let userPromises = users.map(updateUser);
let lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(() => {
processUsers(lastUser._id);
});
}
function updateUser (user) {
count++;
let set = {migration: MIGRATION_NAME};
if (user.items.pets['Bear-Veteran']) {
set['items.pets.Fox-Veteran'] = 5;
} else if (user.items.pets['Lion-Veteran']) {
set['items.pets.Bear-Veteran'] = 5;
} else if (user.items.pets['Tiger-Veteran']) {
set['items.pets.Lion-Veteran'] = 5;
} else if (user.items.pets['Wolf-Veteran']) {
set['items.pets.Tiger-Veteran'] = 5;
} else {
set['items.pets.Wolf-Veteran'] = 5;
}
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return user.update({_id: user._id}, {$set: set}).exec();
}
function displayData () {
console.warn(`\n${count} users processed\n`);
return exiting(0);
}
function exiting (code, msg) {
code = code || 0; // 0 = success
if (code && !msg) {
msg = 'ERROR!';
}
if (msg) {
if (code) {
console.error(msg);
} else {
console.log(msg);
}
}
process.exit(code);
}
module.exports = processUsers;

View File

@@ -1,44 +1,44 @@
export default [
{
name: 'beffymaroo',
type: 'Staff',
uuid: '9fe7183a-4b79-4c15-9629-a1aee3873390',
},
// {
// name: 'lefnire',
// type: 'Staff',
// uuid: '00000000-0000-4000-9000-000000000000',
// },
{
name: 'Lemoness',
type: 'Staff',
uuid: '7bde7864-ebc5-4ee2-a4b7-1070d464cdb0',
},
{
name: 'paglias',
type: 'Staff',
uuid: 'ed4c688c-6652-4a92-9d03-a5a79844174a',
},
{
name: 'redphoenix',
type: 'Staff',
uuid: 'cb46ad54-8c78-4dbc-a8ed-4e3185b2b3ff',
},
{
name: 'paglias',
type: 'Staff',
uuid: 'ed4c688c-6652-4a92-9d03-a5a79844174a',
},
{
name: 'SabreCat',
type: 'Staff',
uuid: '7f14ed62-5408-4e1b-be83-ada62d504931',
},
{
name: 'TheHollidayInn',
type: 'Staff',
uuid: '206039c6-24e4-4b9f-8a31-61cbb9aa3f66',
},
{
name: 'viirus',
type: 'Staff',
uuid: 'a327d7e0-1c2e-41be-9193-7b30b484413f',
},
{
name: 'beffymaroo',
type: 'Staff',
uuid: '9fe7183a-4b79-4c15-9629-a1aee3873390',
},
{
name: 'Apollo',
type: 'Staff',
uuid: '9b2f4123-f749-4f74-85e2-ce31ce778435',
},
{
name: 'Piyo',
type: 'Staff',
uuid: '61b2c855-0a30-444c-bcc6-1cac876460b0',
},
{
name: 'It\'s Bailey',
type: 'Moderator',
@@ -64,11 +64,6 @@ export default [
type: 'Moderator',
uuid: '28771972-ca6d-4c03-8261-e1734aa7d21d',
},
// {
// name: 'Daniel the Bard',
// type: 'Moderator',
// uuid: '1f7c4a74-03a3-4b2c-b015-112d0acbd593',
// },
{
name: 'deilann 5.0.5b',
type: 'Moderator',

View File

@@ -19,6 +19,7 @@
"veteranTiger": "Veteran Tiger",
"veteranLion": "Veteran Lion",
"veteranBear": "Veteran Bear",
"veteranFox": "Veteran Fox",
"cerberusPup": "Cerberus Pup",
"hydra": "Hydra",
"mantisShrimp": "Mantis Shrimp",

View File

@@ -71,6 +71,7 @@ let specialPets = {
'Orca-Base': 'orca',
'Bear-Veteran': 'veteranBear',
'Hippogriff-Hopeful': 'hopefulHippogriffPet',
'Fox-Veteran': 'veteranFox',
};
let specialMounts = {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -3,7 +3,7 @@ import { authWithHeaders } from '../../middlewares/auth';
let api = {};
// @TODO export this const, cannot export it from here because only routes are exported from controllers
const LAST_ANNOUNCEMENT_TITLE = 'HABITICA BLOG: WIKI, USE CASE, AND GUILD SPOTLIGHTS';
const LAST_ANNOUNCEMENT_TITLE = 'VETERAN PETS AND NEW STAFF MEMBERS';
const worldDmg = { // @TODO
bailey: false,
};
@@ -30,19 +30,25 @@ api.getNews = {
<div class="mr-3 ${baileyClass}"></div>
<div class="media-body">
<h1 class="align-self-center">${res.t('newStuff')}</h1>
<h2>10/18/2018 - ${LAST_ANNOUNCEMENT_TITLE}</h2>
<h2>10/23/2018 - ${LAST_ANNOUNCEMENT_TITLE}</h2>
</div>
</div>
<hr/>
<div class="promo_fall_festival_2018 center-block"></div>
<h3>Blog Post: Grand Galas</h3>
<p>This month's <a href='https://habitica.wordpress.com/2018/10/17/grand-gala/' target='_blank'>featured Wiki article</a> is about Habitica's Grand Galas! We hope that it will help you as you enjoy Fall Festival and look forward to our other exciting galas. Be sure to check it out, and let us know what you think by reaching out on <a href='https://twitter.com/habitica' target='_blank'>Twitter</a>, <a href='http://blog.habitrpg.com' target='_blank'>Tumblr</a>, and <a href='https://facebook.com/habitica' target='_blank'>Facebook</a>.</p>
<div class="small mb-3">by shanaqui and the Wiki Wizards</div>
<div class="scene_positivity center-block"></div>
<h3>Use Case Spotlight and Guild Spotlight on Celebrating Yourself</h3>
<p>We've got new posts on the blog all about ways to use Habitica to help with celebrating yourself and your accomplishments ! First, there's a <a href='https://habitica.wordpress.com/2018/10/18/celebrating-your-achievements-guild-spotlight/' target='_blank'>Guild Spotlight</a> that highlights the Guilds that can help you as you explore ways to share your triumphs. We've also posted a <a href='https://habitica.wordpress.com/2018/10/18/use-case-spotlight-celebrate-yourself/' target='_blank'>Use Case Spotlight</a> featuring a number of great suggestions for using Habitica's task system and other areas to share your pride in your victories! These suggestions were submitted by Habiticans in the <a href='/groups/guild/1d3a10bf-60aa-4806-a38b-82d1084a59e6' target='_blank'>Use Case Spotlights Guild</a>.</p>
<p>Plus, we're collecting user submissions for the next Use Case Spotlight! How do you use Habitica to manage healthy habits for sleep and rest? Well be featuring player-submitted examples in Use Case Spotlights on the Habitica Blog next month, so post your suggestions in the Use Case Spotlight Guild now. We look forward to learning more about how you use Habitica to improve your life and get things done!</p>
<div class="small mb-3">by shanaqui</div>
<div class="promo_veteran_pets center-block"></div>
<h3>New Veteran Pet!</h3>
<p>Hello Habiticans! Everyone is doing really well with the transition to our new <a href='https://habitica.wordpress.com/2018/10/11/coming-soon-unique-usernames/' target='_blank'>unique username system</a>!</p>
<p>As a reward for confirming your username, you've been granted a veteran pet! If you haven't confimed yet, your new pet will appear in your Stable as soon as you do. Which pet? That depends on how many major changes to Habitica you've been around for.</p>
<p>Enjoy, and thank you for being part of our community- it means a lot to us! <3</p>
<div class="small mb-3">by Beffymaroo, SabreCat, Apollo, Piyo, viirus, Paglias, and TheHollidayInn</div>
<div class="media align-items-center">
<div class="npc_apollo ml-3"></div>
<div class="media-body">
<h3>New Staff Members: Apollo and Piyo</h3>
<p>We're thrilled to announce that our long-time designers Apollo and Piyo will be coming onboard as staff members! They've done a lot of beautiful work on the site and the mobile apps and we couldn't be happier to welcome them aboard. Go congratulate them in <a href='/groups/tavern'>the Tavern</a>!</p>
<div class="small mb-3">by the Habitica Team</div>
</div>
<div class="npc_piyo mr-3"></div>
</div>
</div>
`,
});

View File

@@ -62,7 +62,20 @@ api.updateUsername = {
// save username
user.auth.local.lowerCaseUsername = newUsername.toLowerCase();
user.auth.local.username = newUsername;
if (!user.flags.verifiedUsername) {
user.flags.verifiedUsername = true;
if (user.items.pets['Bear-Veteran']) {
user.items.pets['Fox-Veteran'] = 5;
} else if (user.items.pets['Lion-Veteran']) {
user.items.pets['Bear-Veteran'] = 5;
} else if (user.items.pets['Tiger-Veteran']) {
user.items.pets['Lion-Veteran'] = 5;
} else if (user.items.pets['Wolf-Veteran']) {
user.items.pets['Tiger-Veteran'] = 5;
} else {
user.items.pets['Wolf-Veteran'] = 5;
}
}
await user.save();
res.respond(200, { username: req.body.username });

View File

@@ -125,6 +125,7 @@ function _setUpNewUser (user) {
let iterableFlags = user.flags.toObject();
user.items.quests.dustbunnies = 1;
user.items.pets['Wolf-Veteran'] = 5; // Thank-you for users joining during username upheaval
user.purchased.background.violet = true;
user.preferences.background = 'violet';