2021-11-02 10:34:08 +00:00
|
|
|
// Run all the mongo queries on secondaries
|
|
|
|
process.env.MONGO_CONNECTION_STRING =
|
|
|
|
process.env.READ_ONLY_MONGO_CONNECTION_STRING
|
|
|
|
|
2020-10-05 08:29:37 +00:00
|
|
|
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
2019-07-11 18:45:50 +00:00
|
|
|
const InstitutionsManager = require('../app/src/Features/Institutions/InstitutionsManager')
|
2019-01-28 14:18:01 +00:00
|
|
|
|
|
|
|
const institutionId = parseInt(process.argv[2])
|
|
|
|
if (isNaN(institutionId)) throw new Error('No institution id')
|
|
|
|
console.log('Checking users of institution', institutionId)
|
2021-08-18 14:56:07 +00:00
|
|
|
const emitNonProUserIds = process.argv.includes('--emit-non-pro-user-ids')
|
2019-01-28 14:18:01 +00:00
|
|
|
|
2020-10-05 08:29:37 +00:00
|
|
|
waitForDb()
|
|
|
|
.then(main)
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
|
|
|
|
2021-07-27 13:23:22 +00:00
|
|
|
async function main() {
|
|
|
|
const usersSummary = await InstitutionsManager.promises.checkInstitutionUsers(
|
2021-08-18 14:56:07 +00:00
|
|
|
institutionId,
|
|
|
|
emitNonProUserIds
|
2021-04-14 13:17:21 +00:00
|
|
|
)
|
2021-07-27 13:23:22 +00:00
|
|
|
console.log(usersSummary)
|
|
|
|
process.exit()
|
2020-10-05 08:29:37 +00:00
|
|
|
}
|