Redesign: Veteran Pet migration (#9090)

* feat(migration): add Veteran pets
Also refactor pinned items query to fetch less data

* refactor(migration): rename/move, not duplicate
This commit is contained in:
Sabe Jones 2017-09-27 19:47:04 -05:00 committed by GitHub
parent f4bf2df4a9
commit 08a84ce13d
4 changed files with 23 additions and 2 deletions

View file

@ -1,12 +1,13 @@
var updateStore = require('../website/common/script/libs/updateStore');
var getItemInfo = require('../website/common/script/libs/getItemInfo');
var migrationName = '20170811_pinned_items.js';
var migrationName = '20170928_redesign_launch.js';
var authorName = 'paglias'; // in case script author needs to know when their ...
var authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; //... own data is done
/*
* Migrate existing in app rewards lists to pinned items
* Award Veteran Pets
*/
var monk = require('monk');
@ -16,9 +17,16 @@ var dbUsers = monk(connectionString).get('users', { castIds: false });
function processUsers(lastId) {
// specify a query to limit the affected users (empty for all users):
var query = {
'migration':{$ne:migrationName},
'migration': {$ne:migrationName},
'auth.timestamps.loggedin': {$gt: new Date('2017-09-21')},
};
var fields = {
'items.pets': 1,
'items.gear': 1,
'stats.class': 1,
}
if (lastId) {
query._id = {
$gt: lastId
@ -26,6 +34,7 @@ function processUsers(lastId) {
}
return dbUsers.find(query, {
fields: fields,
sort: {_id: 1},
limit: 250,
})
@ -84,6 +93,16 @@ function updateUser (user) {
set.pinnedItems = newPinnedItems;
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);
if (user._id == authorUuid) console.warn(authorName + ' processed');

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -18,6 +18,7 @@
"veteranWolf": "Veteran Wolf",
"veteranTiger": "Veteran Tiger",
"veteranLion": "Veteran Lion",
"veteranBear": "Veteran Bear",
"cerberusPup": "Cerberus Pup",
"hydra": "Hydra",
"mantisShrimp": "Mantis Shrimp",

View file

@ -69,6 +69,7 @@ let specialPets = {
'JackOLantern-Ghost': 'ghostJackolantern',
'Jackalope-RoyalPurple': 'royalPurpleJackalope',
'Orca-Base': 'orca',
'Bear-Veteran': 'veteranBear',
};
let specialMounts = {