mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
db162cfe0a
Use path.join() in reintroduce beta script to pass linting GitOrigin-RevId: 4936de04b389571e73de3ddcae8ee611634efcaf
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const mongojs = require('../../app/js/infrastructure/mongojs')
|
|
const { db, ObjectId } = mongojs
|
|
const async = require('async')
|
|
|
|
console.log('Finding users for ids specified')
|
|
|
|
const text = fs.readFileSync(path.join(__dirname, 'beta-users.txt'))
|
|
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)
|
|
}
|
|
})
|