diff --git a/package.json b/package.json index aa192cae7..fc326df34 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "coffeelint-brunch": "^1.7.1", "commonjs-require-definition": "0.2.0", "compressible": "~1.0.1", + "country-data": "0.0.24", "country-list": "0.0.3", "css-brunch": "^1.7.0", "fs-extra": "^0.26.2", diff --git a/scripts/mongodb/migrations/2016-05-19-enrollment-start-end-dates.js b/scripts/mongodb/migrations/2016-05-19-enrollment-start-end-dates.js index 659e9c666..fe3d8160a 100644 --- a/scripts/mongodb/migrations/2016-05-19-enrollment-start-end-dates.js +++ b/scripts/mongodb/migrations/2016-05-19-enrollment-start-end-dates.js @@ -1,10 +1,16 @@ // Migrate users from coursePrepaidID to coursePrepaid -startDate = new Date(Date.UTC(2016,4,22)).toISOString(); // NOTE: Month is 0 indexed... -endDate = new Date(Date.UTC(2017,4,22)).toISOString(); -print('Setting start/end', startDate, endDate); +startDate = new Date(Date.UTC(2016,4,15)).toISOString(); // NOTE: Month is 0 indexed... +endDate = new Date(Date.UTC(2017,5,1)).toISOString(); -db.prepaids.find({type: 'course'}).limit(10).forEach(function (prepaid) { +cutoffDate = new Date(2015,11,11); +cutoffID = ObjectId(Math.floor(cutoffDate/1000).toString(16)+'0000000000000000'); + +print('Setting start/end', startDate, endDate, cutoffID); + +var cursor = db.prepaids.find({type: 'course', _id: { $gt: cutoffID }}) + +cursor.forEach(function (prepaid) { var properties = prepaid.properties || {}; if (!(prepaid.endDate && prepaid.startDate)) { if (!prepaid.endDate) { @@ -19,21 +25,21 @@ db.prepaids.find({type: 'course'}).limit(10).forEach(function (prepaid) { if (!prepaid.startDate) { prepaid.startDate = startDate; } - print('updating prepaid', JSON.stringify(prepaid, null, '\t')); - //print(db.prepaids.save(prepaid)); + print('updating prepaid', prepaid._id, 'creator', prepaid.creator, 'start/end', prepaid.startDate, prepaid.endDate); + print(' -', db.prepaids.save(prepaid)); } var redeemers = prepaid.redeemers || []; for (var index in redeemers) { var redeemer = redeemers[index]; - var user = db.users.findOne({ _id: redeemer.userID }, { coursePrepaid: 1, coursePrepaidID: 1 }); + var user = db.users.findOne({ _id: redeemer.userID }, { coursePrepaid: 1, coursePrepaidID: 1, email:1, name:1, permissions: 1 }); if (user.coursePrepaidID && !user.coursePrepaid) { var update = { $set: { coursePrepaid: { _id: user.coursePrepaidID, startDate: prepaid.startDate, endDate: prepaid.endDate } }, $unset: { coursePrepaidID: '' } } - print('updating user', JSON.stringify(user, null, ' '), JSON.stringify(update, null, ' ')); - //print(db.users.update({_id: user._id}, update)); + print('\t updating user', user._id, user.name, user.email, user.permissions, JSON.stringify(update)); + print('\t', db.users.update({_id: user._id}, update)); } } diff --git a/scripts/updateCloseIoLeads.js b/scripts/updateCloseIoLeads.js index 84c19c83f..68ddd783b 100644 --- a/scripts/updateCloseIoLeads.js +++ b/scripts/updateCloseIoLeads.js @@ -1,8 +1,8 @@ // Upsert new lead data into Close.io 'use strict'; -if (process.argv.length !== 8) { - log("Usage: node