overleaf/services/web/scripts/check_institution_users.mjs
Jakob Ackermann a7517eefcb Merge pull request #21427 from overleaf/jpa-populate-db-on-import
[web] populate db with collections on import, ahead of waitForDb() call

GitOrigin-RevId: 7eb4cd61c2052187acd9947d7060f54d9822d314
2024-11-01 09:05:15 +00:00

25 lines
761 B
JavaScript

import InstitutionsManager from '../app/src/Features/Institutions/InstitutionsManager.js'
import { ensureRunningOnMongoSecondaryWithTimeout } from './helpers/env_variable_helper.mjs'
ensureRunningOnMongoSecondaryWithTimeout(300000)
const institutionId = parseInt(process.argv[2])
if (isNaN(institutionId)) throw new Error('No institution id')
console.log('Checking users of institution', institutionId)
const emitNonProUserIds = process.argv.includes('--emit-non-pro-user-ids')
async function main() {
const usersSummary = await InstitutionsManager.promises.checkInstitutionUsers(
institutionId,
emitNonProUserIds
)
console.log(usersSummary)
process.exit()
}
try {
await main()
} catch (error) {
console.error(error)
process.exit(1)
}