2022-10-17 06:13:35 -04:00
|
|
|
process.env.MONGO_SOCKET_TIMEOUT = '300000'
|
2021-11-02 06:34:08 -04:00
|
|
|
// Run all the mongo queries on secondaries
|
|
|
|
process.env.MONGO_CONNECTION_STRING =
|
|
|
|
process.env.READ_ONLY_MONGO_CONNECTION_STRING
|
|
|
|
|
2020-10-05 04:29:37 -04:00
|
|
|
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
2019-07-11 14:45:50 -04:00
|
|
|
const InstitutionsManager = require('../app/src/Features/Institutions/InstitutionsManager')
|
2019-01-28 09:18:01 -05: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 10:56:07 -04:00
|
|
|
const emitNonProUserIds = process.argv.includes('--emit-non-pro-user-ids')
|
2019-01-28 09:18:01 -05:00
|
|
|
|
2020-10-05 04:29:37 -04:00
|
|
|
waitForDb()
|
|
|
|
.then(main)
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
|
|
|
|
2021-07-27 09:23:22 -04:00
|
|
|
async function main() {
|
|
|
|
const usersSummary = await InstitutionsManager.promises.checkInstitutionUsers(
|
2021-08-18 10:56:07 -04:00
|
|
|
institutionId,
|
|
|
|
emitNonProUserIds
|
2021-04-14 09:17:21 -04:00
|
|
|
)
|
2021-07-27 09:23:22 -04:00
|
|
|
console.log(usersSummary)
|
|
|
|
process.exit()
|
2020-10-05 04:29:37 -04:00
|
|
|
}
|