mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-17 09:58:45 +00:00
Merge pull request #3048 from overleaf/cmg-wfh-export
Export user details from WFH 2020 subscriptions GitOrigin-RevId: 4f9be9d2b6309f7766f2855b571b81fc40870081
This commit is contained in:
parent
d1b8d49355
commit
a4f4617b03
1 changed files with 41 additions and 0 deletions
41
services/web/scripts/wfh_2020/wfh_2020_export.js
Normal file
41
services/web/scripts/wfh_2020/wfh_2020_export.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
const mongojs = require('../../app/src/infrastructure/mongojs')
|
||||
const { db } = mongojs
|
||||
const async = require('async')
|
||||
|
||||
db.subscriptions.aggregate(
|
||||
{ $match: { teamName: /(Work From Home|Work from Home)/ } },
|
||||
{ $unwind: '$member_ids' },
|
||||
{ $group: { _id: null, memberIds: { $addToSet: '$member_ids' } } },
|
||||
function(err, results) {
|
||||
if (err || !results.length) {
|
||||
throw err
|
||||
}
|
||||
|
||||
const userIds = results[0].memberIds
|
||||
|
||||
console.log('Id,First Name,Last Name,Sign Up Date,Emails')
|
||||
|
||||
async.eachLimit(
|
||||
userIds,
|
||||
10,
|
||||
function(userId, callback) {
|
||||
db.users.findOne(userId, function(err, user) {
|
||||
const emails = user.emails.map(email => email.email)
|
||||
console.log(
|
||||
`${user._id},${user.first_name || ''},${user.last_name || ''},${
|
||||
user.signUpDate
|
||||
},${emails.join(',')}`
|
||||
)
|
||||
callback(err)
|
||||
})
|
||||
},
|
||||
function(err) {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
process.exit(0)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
Loading…
Add table
Reference in a new issue