Naming Day and Take This migrations (#7838)

* feat(migrations): Naming Day and Take This

* fix(migration): more goodies, better query

* fix(migration): query in wrong migration

* fix(migration): don't award goodies repeatedly

* fix(migrations): move logic to query

* fix(migrations): better field lookup

* fix(migrations): use timeouts
This commit is contained in:
Sabe Jones
2016-07-31 18:55:57 -05:00
committed by GitHub
parent 6804125068
commit e021212481
5 changed files with 160 additions and 15 deletions

View File

@@ -6,23 +6,19 @@ var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
* set the newStuff flag in all user accounts so they see a Bailey message
*/
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
var dbname = 'habitrpg';
var mongo = require('mongoskin');
var _ = require('lodash');
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
var dbUsers = mongo.db(connectionString).collection('users');
// specify a query to limit the affected users (empty for all users):
var query = {
'flags.newStuff':false
'flags.newStuff':{$ne:true}
};
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
var fields = {
'flags.newStuff':1
};
console.warn('Updating users...');
@@ -32,7 +28,8 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
if (err) { return exiting(1, 'ERROR! ' + err); }
if (!user) {
console.warn('All appropriate users found and modified.');
return displayData();
setTimeout(displayData, 300000);
return;
}
count++;