Merge pull request #4760 from overleaf/em-explicitly-start-queue-workers
Start queue workers explicitly GitOrigin-RevId: 0f8b710e0f1c0d64efa04f46fec269fae53609b2
This commit is contained in:
@@ -4,22 +4,14 @@ const {
|
||||
promises: InstitutionsAPIPromises,
|
||||
} = require('../Institutions/InstitutionsAPI')
|
||||
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
||||
const Features = require('../../infrastructure/Features')
|
||||
|
||||
const ONE_DAY_MS = 24 * 60 * 60 * 1000
|
||||
|
||||
class UserPostRegistrationAnalyticsManager {
|
||||
constructor() {
|
||||
this.queue = Queues.getPostRegistrationAnalyticsQueue()
|
||||
this.queue.process(async job => {
|
||||
const { userId } = job.data
|
||||
await postRegistrationAnalytics(userId)
|
||||
})
|
||||
}
|
||||
|
||||
async schedulePostRegistrationAnalytics(user) {
|
||||
await this.queue.add({ userId: user._id }, { delay: ONE_DAY_MS })
|
||||
}
|
||||
async function schedulePostRegistrationAnalytics(user) {
|
||||
await Queues.getPostRegistrationAnalyticsQueue().add(
|
||||
{ userId: user._id },
|
||||
{ delay: ONE_DAY_MS }
|
||||
)
|
||||
}
|
||||
|
||||
async function postRegistrationAnalytics(userId) {
|
||||
@@ -48,10 +40,7 @@ async function checkAffiliations(userId) {
|
||||
}
|
||||
}
|
||||
|
||||
class NoopManager {
|
||||
async schedulePostRegistrationAnalytics() {}
|
||||
module.exports = {
|
||||
schedulePostRegistrationAnalytics,
|
||||
postRegistrationAnalytics,
|
||||
}
|
||||
|
||||
module.exports = Features.hasFeature('saas')
|
||||
? new UserPostRegistrationAnalyticsManager()
|
||||
: new NoopManager()
|
||||
|
||||
Reference in New Issue
Block a user