mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3032 from overleaf/msm-added-user-find-projections-scripts
Deleted scripts no longer needed GitOrigin-RevId: 822aef0dbea7f2e7f664cb939ed75c9c658c00f5
This commit is contained in:
parent
88683e9fec
commit
b982493e08
4 changed files with 0 additions and 221 deletions
|
@ -1,50 +0,0 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const mongojs = require('../../app/src/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)
|
||||
}
|
||||
})
|
|
@ -1,72 +0,0 @@
|
|||
const { db } = require('../../app/src/infrastructure/mongojs')
|
||||
const DropboxHandler = require('../../modules/dropbox/app/src/DropboxHandler')
|
||||
const EmailHandler = require('../../app/src/Features/Email/EmailHandler')
|
||||
const async = require('async')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const commit = argv.commit !== undefined
|
||||
|
||||
if (!commit) {
|
||||
console.log('DOING DRY RUN. TO SAVE CHANGES PASS --commit')
|
||||
}
|
||||
|
||||
db.users.aggregate(
|
||||
[
|
||||
{
|
||||
$group: {
|
||||
// group by Dropbox access token uid and count distinct users
|
||||
_id: '$dropbox.access_token.uid',
|
||||
count: { $sum: 1 },
|
||||
_ids: { $addToSet: '$_id' }
|
||||
}
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
// select only uids userd more than once
|
||||
_id: { $ne: null },
|
||||
count: { $gt: 1 }
|
||||
}
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
// filter output
|
||||
_id: false,
|
||||
dropbox_uid: '$_id',
|
||||
_ids: '$_ids'
|
||||
}
|
||||
}
|
||||
],
|
||||
{ allowDiskUse: true },
|
||||
function(error, results) {
|
||||
if (error) throw error
|
||||
console.log('FOUND ' + results.length + ' DUPLICATES')
|
||||
async.mapSeries(results, removeDuplicates, function(error) {
|
||||
if (error) throw error
|
||||
console.log('DONE')
|
||||
process.exit()
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
function removeDuplicates(duplicate, callback) {
|
||||
async.mapSeries(duplicate._ids, unlinkUser, function(error) {
|
||||
callback(error)
|
||||
})
|
||||
}
|
||||
|
||||
function unlinkUser(_id, callback) {
|
||||
db.users.findOne({ _id: _id }, function(error, user) {
|
||||
if (error) return callback(error)
|
||||
console.log('UNLINKING USER ' + _id + ' (' + user.email + ')')
|
||||
if (!commit) return callback()
|
||||
DropboxHandler.unlinkAccount(_id, function(error) {
|
||||
if (error) return callback(error)
|
||||
EmailHandler.sendEmail(
|
||||
'dropboxUnlinkedDuplicate',
|
||||
{ to: user.email },
|
||||
callback
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
const { db } = require('../app/src/infrastructure/mongojs')
|
||||
const async = require('async')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const argv = minimist(process.argv.slice(2))
|
||||
const commit = argv.commit !== undefined
|
||||
|
||||
if (!commit) {
|
||||
console.log('DOING DRY RUN. TO SAVE CHANGES PASS --commit')
|
||||
}
|
||||
|
||||
db.users.aggregate(
|
||||
[
|
||||
{ $match: { 'overleaf.id': { $exists: true } } },
|
||||
{ $group: { _id: '$overleaf.id', count: { $sum: 1 } } },
|
||||
{ $match: { count: { $gt: 1 } } }
|
||||
],
|
||||
{ allowDiskUse: true },
|
||||
function(err, results) {
|
||||
if (err) throw err
|
||||
console.log('FOUND ' + results.length + ' DUPLICATES')
|
||||
async.mapSeries(results, removeDuplicates, function(err) {
|
||||
if (err) throw err
|
||||
console.log('DONE')
|
||||
process.exit()
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
function removeDuplicates(duplicate, callback) {
|
||||
db.users.findOne({ 'overleaf.id': duplicate._id }, function(err, keepUser) {
|
||||
if (err) throw err
|
||||
console.log('KEEPING USER ' + keepUser._id + ' FOR OL ' + duplicate._id)
|
||||
db.users.find(
|
||||
{ 'overleaf.id': duplicate._id, _id: { $ne: keepUser._id } },
|
||||
function(err, duplicateUsers) {
|
||||
if (err) throw err
|
||||
async.mapSeries(
|
||||
duplicateUsers,
|
||||
function(user, cb) {
|
||||
console.log(
|
||||
'UNLINKING USER ' + user._id + ' FOR OL ' + duplicate._id
|
||||
)
|
||||
if (!commit) return cb()
|
||||
db.users.update(
|
||||
{ _id: user._id },
|
||||
{ $unset: { 'overleaf.id': '' } },
|
||||
cb
|
||||
)
|
||||
},
|
||||
function(err) {
|
||||
if (err) throw err
|
||||
callback()
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--ignore-pattern frontend/js/vendor \
|
||||
--noSemi=true \
|
||||
frontend/js
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
test/frontend
|
||||
|
||||
for MODULE in admin-panel cms dropbox git-bridge github-sync launchpad metrics open-in-overleaf overleaf-integration portals references-search support templates tpr-webmodule two-factor-authentication v2-templates
|
||||
do
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/$MODULE/frontend/js
|
||||
done
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/rich-text/frontend/js
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/rich-text/test/frontend
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/publish-modal/frontend/js
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/publish-modal/test/frontend
|
||||
|
||||
make format_fix
|
Loading…
Reference in a new issue