switch from Q to Bluebird

This commit is contained in:
Matteo Pagliazzi
2016-05-11 14:34:01 +02:00
parent 299ed624f5
commit cee7700a50
43 changed files with 230 additions and 201 deletions
+3 -3
View File
@@ -30,7 +30,7 @@ var MONGODB_NEW = nconf.get('MONGODB_NEW');
var MongoClient = MongoDB.MongoClient;
mongoose.Promise = Q.Promise; // otherwise mongoose models won't work
mongoose.Promise = Bluebird.all; // otherwise mongoose models won't work
// Load new models
var NewChallenge = require('../../website/src/models/challenge').model;
@@ -165,7 +165,7 @@ function processChallenges (afterId) {
console.log(`Saving ${oldChallenges.length} challenges and ${processedTasks} tasks.`);
return Q.all([
return Bluebird.all([
batchInsertChallenges.execute(),
batchInsertTasks.execute(),
]);
@@ -187,7 +187,7 @@ function processChallenges (afterId) {
}
// Connect to the databases
Q.all([
Bluebird.all([
MongoClient.connect(MONGODB_OLD),
MongoClient.connect(MONGODB_NEW),
])
+3 -3
View File
@@ -30,7 +30,7 @@ var MONGODB_NEW = nconf.get('MONGODB_NEW');
var MongoClient = MongoDB.MongoClient;
mongoose.Promise = Q.Promise; // otherwise mongoose models won't work
mongoose.Promise = Bluebird.all; // otherwise mongoose models won't work
// To be defined later when MongoClient connects
var mongoDbOldInstance;
@@ -103,7 +103,7 @@ function processChallenges (afterId) {
console.log(`Migrating members of ${oldChallenges.length} challenges.`);
return Q.all(promises);
return Bluebird.all(promises);
})
.then(function () {
processedChallenges += oldChallenges.length;
@@ -119,7 +119,7 @@ function processChallenges (afterId) {
}
// Connect to the databases
Q.all([
Bluebird.all([
MongoClient.connect(MONGODB_OLD),
MongoClient.connect(MONGODB_NEW),
])
+2 -2
View File
@@ -29,7 +29,7 @@ var MONGODB_NEW = nconf.get('MONGODB_NEW');
var MongoClient = MongoDB.MongoClient;
mongoose.Promise = Q.Promise; // otherwise mongoose models won't work
mongoose.Promise = Bluebird.all; // otherwise mongoose models won't work
// Load new models
var Coupon = require('../../website/src/models/coupon').model;
@@ -112,7 +112,7 @@ function processCoupons (afterId) {
}
// Connect to the databases
Q.all([
Bluebird.all([
MongoClient.connect(MONGODB_OLD),
MongoClient.connect(MONGODB_NEW),
])
+2 -2
View File
@@ -29,7 +29,7 @@ var MONGODB_NEW = nconf.get('MONGODB_NEW');
var MongoClient = MongoDB.MongoClient;
mongoose.Promise = Q.Promise; // otherwise mongoose models won't work
mongoose.Promise = Bluebird.all; // otherwise mongoose models won't work
// Load new models
var EmailUnsubscription = require('../../website/src/models/emailUnsubscription').model;
@@ -113,7 +113,7 @@ function processUnsubscriptions (afterId) {
}
// Connect to the databases
Q.all([
Bluebird.all([
MongoClient.connect(MONGODB_OLD),
MongoClient.connect(MONGODB_NEW),
])
+3 -3
View File
@@ -37,7 +37,7 @@ var MONGODB_NEW = nconf.get('MONGODB_NEW');
var MongoClient = MongoDB.MongoClient;
mongoose.Promise = Q.Promise; // otherwise mongoose models won't work
mongoose.Promise = Bluebird.all; // otherwise mongoose models won't work
// Load new models
var NewGroup = require('../../website/src/models/group').model;
@@ -166,7 +166,7 @@ function processGroups (afterId) {
console.log(`Saving ${oldGroups.length} groups and migrating members to users collection.`);
promises.push(batchInsertGroups.execute());
return Q.all(promises);
return Bluebird.all(promises);
})
.then(function () {
processedGroups += oldGroups.length;
@@ -182,7 +182,7 @@ function processGroups (afterId) {
}
// Connect to the databases
Q.all([
Bluebird.all([
MongoClient.connect(MONGODB_OLD),
MongoClient.connect(MONGODB_NEW),
])
+3 -3
View File
@@ -33,7 +33,7 @@ var MONGODB_NEW = nconf.get('MONGODB_NEW');
var taskDefaults = common.taskDefaults;
var MongoClient = MongoDB.MongoClient;
mongoose.Promise = Q.Promise; // otherwise mongoose models won't work
mongoose.Promise = Bluebird.all; // otherwise mongoose models won't work
// Load new models
var NewUser = require('../../website/src/models/user').model;
@@ -196,7 +196,7 @@ function processUsers (afterId) {
console.log(`Saving ${oldUsers.length} users and ${processedTasks} tasks.`);
return Q.all([
return Bluebird.all([
batchInsertUsers.execute(),
batchInsertTasks.execute(),
]);
@@ -218,7 +218,7 @@ function processUsers (afterId) {
}
// Connect to the databases
Q.all([
Bluebird.all([
MongoClient.connect(MONGODB_OLD),
MongoClient.connect(MONGODB_NEW),
])