2019-03-22 08:21:00 -04:00
|
|
|
const fs = require('fs')
|
2019-03-22 08:48:28 -04:00
|
|
|
const path = require('path')
|
2019-07-11 14:45:50 -04:00
|
|
|
const mongojs = require('../../app/src/infrastructure/mongojs')
|
2019-03-22 08:21:00 -04:00
|
|
|
const { db, ObjectId } = mongojs
|
|
|
|
const async = require('async')
|
|
|
|
|
|
|
|
console.log('Finding users for ids specified')
|
|
|
|
|
2019-03-22 08:48:28 -04:00
|
|
|
const text = fs.readFileSync(path.join(__dirname, 'beta-users.txt'))
|
2019-03-22 08:21:00 -04:00
|
|
|
const textByLine = text
|
|
|
|
.toString()
|
|
|
|
.split('\n')
|
|
|
|
.map(function(stringId) {
|
|
|
|
return ObjectId(stringId)
|
|
|
|
})
|
|
|
|
|
|
|
|
db.users.find({ _id: { $in: textByLine } }, function(err, users) {
|
|
|
|
if (err) throw err
|
|
|
|
|
|
|
|
if (users.length) {
|
|
|
|
console.log('Found ' + users.length + ' users')
|
|
|
|
|
|
|
|
async.each(
|
|
|
|
users,
|
|
|
|
function(user, callback) {
|
|
|
|
console.log('setting betaProgram==true for: ' + user._id)
|
|
|
|
db.users.update(
|
|
|
|
{
|
|
|
|
_id: user._id
|
|
|
|
},
|
|
|
|
{
|
|
|
|
$set: {
|
|
|
|
betaProgram: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
callback
|
|
|
|
)
|
|
|
|
},
|
|
|
|
function(result, err) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
|
|
|
process.exit(0)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
console.log('No users found matching those ids')
|
|
|
|
process.exit(0)
|
|
|
|
}
|
|
|
|
})
|