chore(news): Bailey

and tweak today's migrations for new format
This commit is contained in:
Sabe Jones
2017-02-02 21:04:36 +00:00
parent 7a534ab81d
commit c391de9e86
3 changed files with 84 additions and 35 deletions

View File

@@ -10,7 +10,6 @@ var monk = require('monk');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
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 = {
@@ -45,10 +44,10 @@ function updateUsers (users) {
return;
}
var userPaymentPromises = users.map(updateUser);
var userPromises = users.map(updateUser);
var lastUser = users[users.length - 1];
return Promise.all(userPaymentPromises)
return Promise.all(userPromises)
.then(function () {
processUsers(lastUser._id);
});

View File

@@ -6,49 +6,69 @@ var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
* Remove flag stating that the Enchanted Armoire is empty, for when new equipment is added
*/
var mongo = require('mongoskin');
var monk = require('monk');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = monk(connectionString).get('users', { castIds: false });
var dbUsers = mongo.db(connectionString).collection('users');
function processUsers(lastId) {
// specify a query to limit the affected users (empty for all users):
var query = {
'flags.armoireEmpty': true,
};
// specify a query to limit the affected users (empty for all users):
var query = {
'flags.armoireEmpty':true
};
if (lastId) {
query._id = {
$gt: lastId
}
}
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
};
dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
fields: [] // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
})
.then(updateUsers)
.catch(function (err) {
console.log(err);
return exiting(1, 'ERROR! ' + err);
});
}
console.warn('Updating users...');
var progressCount = 1000;
var count = 0;
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
setTimeout(displayData, 300000);
displayData();
return;
}
var userPromises = users.map(updateUser);
var lastUser = users[users.length - 1];
return Promise.all(userPromises)
.then(function () {
processUsers(lastUser._id);
});
}
function updateUser (user) {
count++;
// specify user data to change:
var set = {'migration':migrationName, 'flags.armoireEmpty':false};
var set = {'migration': migrationName, 'flags.armoireEmpty': false};
dbUsers.update({_id:user._id}, {$set:set});
dbUsers.update({_id: user._id}, {$set:set});
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
if (count % progressCount == 0) console.warn(count + ' ' + user._id);
if (user._id == authorUuid) console.warn(authorName + ' processed');
});
}
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!'; }
@@ -58,3 +78,5 @@ function exiting(code, msg) {
}
process.exit(code);
}
module.exports = processUsers;

View File

@@ -1,27 +1,55 @@
h2 2/1/2017 - RESOLUTIONS CHALLENGE AND TAKE THIS CHALLENGES CONCLUDED; NEW TAKE THIS CHALLENGE
h2 2/2/2017 - CUPID HATCHING POTIONS, SUBSCRIPTIONS ON ANDROID, NEW BACKGROUNDS, AND NEW ARMOIRE ITEMS
hr
tr
td
h3 Resolution Challenge Winners
p The winners of the Habitica New Years Resolutions Challenge have been selected! Congratulations to: thesuperalice, booksandchips, Meriah, hazey_sunshine, and Valendro!
.promo_cupid_potions.pull-left.slight-right-margin
.promo_backgrounds_armoire_201702.pull-right
h3 Cupid Hatching Potions
p There's a new pet breed in town! Between now and February 28th, you can buy Cupid Hatching Potions from <a href='/#/options/inventory/drops'>the Market</a> and use them to hatch any standard pet egg. (Magic Hatching Potions do not work on Quest Pet eggs.) Cupid Potion Pets aren't picky, so they'll happily eat any kind of food that you feed them!
br
p Thank you to everyone who shared your resolutions! We're excited to help you pursue your goals throughout 2017 and beyond!
p After they're gone, it will be at least a year before the Cupid Hatching Potions are available again, so be sure to get them now!
p.small.muted by Willow the Witty and SabreCat
tr
td
.promo_takeThis_gear.pull-left.slight-right-margin
h3 New Take This Challenge
p The next Take This Challenge has launched, <a href='/#/options/groups/challenges/1b242bc7-73a8-4307-aa97-7be7d9a3d1a0'>Notice Me, Senpai!</a>, with a focus on reaching out to others when you're struggling. Be sure to check it out to earn additional pieces of the Take This armor set!
h3 Android Update: Subscriptions
p There's an exciting new update to our [Android app] (https://play.google.com/store/apps/details?id=com.habitrpg.android.habitica&hl=en). You can now subscribe to Habitica through the app!
br
p <a href='http://www.takethis.org/' target='_blank'>Take This</a> is a nonprofit that seeks to inform the gamer community about mental health issues, to provide education about mental disorders and mental illness prevention, and to reduce the stigma of mental illness.
p Subscribers help us keep the app running and updating, so as a thank-you, they get exclusive monthly items, the ability to buy gems with gold, and more!
br
p Congratulations to the winners of the last Take This Challenge, "Multiplayer Co-op Exercise": grand prize winner IvokaOrange, and runners-up nerelleaustralis, Millificent, Soul Brig, wwwave, and Arawasa the Unseen! Plus, all participants in that Challenge have received a piece of the <a href='http://habitica.wikia.com/wiki/Event_Item_Sequences#Take_This_Armor_Set' target='_blank'>Take This item set</a> if they didn't have all the pieces already. It is located in your Rewards column. Enjoy!
p.small.muted by Doctor B, the Take This team, Lemoness, and SabreCat
p If you're already a subscriber, you can now use the app to open your monthly gift and buy gems with gold! Thank you for your support, it means a lot to us!
br
p Weve also done some minor bug fixes. Be sure to download the update now for a better Habitica experience! If you like the improvements that weve been making to our app, please consider reviewing this new version. It really helps us out!
p.small.muted by Viirus
tr
td
h3 New Backgrounds and Armoire Items
p Weve added three new backgrounds to the <a href='/#/options/profile/backgrounds'>Background Shop</a>! Now your avatar can climb to the Bell Tower, bask in the wealth of a Treasure Room and pose under the Wedding Arch.
br
p Plus, theres new gold-purchasable equipment in the Enchanted Armoire, including the Queen of Hearts set. Better work hard on your real-life tasks to earn all the pieces! Enjoy :)
p.small.muted by Casey, AnnDeLune, and CitrineSun
if menuItem !== 'oldNews'
hr
a(href='/static/old-news', target='_blank') Read older news
mixin oldNews
h2 2/1/2017 - RESOLUTIONS CHALLENGE AND TAKE THIS CHALLENGES CONCLUDED; NEW TAKE THIS CHALLENGE
tr
td
h3 Resolution Challenge Winners
p The winners of the Habitica New Years Resolutions Challenge have been selected! Congratulations to: thesuperalice, booksandchips, Meriah, hazey_sunshine, and Valendro!
br
p Thank you to everyone who shared your resolutions! We're excited to help you pursue your goals throughout 2017 and beyond!
tr
td
.promo_takeThis_gear.pull-left.slight-right-margin
h3 New Take This Challenge
p The next Take This Challenge has launched, <a href='/#/options/groups/challenges/1b242bc7-73a8-4307-aa97-7be7d9a3d1a0'>Notice Me, Senpai!</a>, with a focus on reaching out to others when you're struggling. Be sure to check it out to earn additional pieces of the Take This armor set!
br
p <a href='http://www.takethis.org/' target='_blank'>Take This</a> is a nonprofit that seeks to inform the gamer community about mental health issues, to provide education about mental disorders and mental illness prevention, and to reduce the stigma of mental illness.
br
p Congratulations to the winners of the last Take This Challenge, "Multiplayer Co-op Exercise": grand prize winner IvokaOrange, and runners-up nerelleaustralis, Millificent, Soul Brig, wwwave, and Arawasa the Unseen! Plus, all participants in that Challenge have received a piece of the <a href='http://habitica.wikia.com/wiki/Event_Item_Sequences#Take_This_Armor_Set' target='_blank'>Take This item set</a> if they didn't have all the pieces already. It is located in your Rewards column. Enjoy!
p.small.muted by Doctor B, the Take This team, Lemoness, and SabreCat
h2 1/31/2017 - HABITICA BIRTHDAY PARTY AND LAST CHANCE FOR MANY SPECIAL ITEMS
tr
td