diff --git a/config/default.js b/config/default.js index 6a8cfef3..3433b840 100644 --- a/config/default.js +++ b/config/default.js @@ -275,6 +275,8 @@ module.exports = { INTERVIEW_COMPLETED_PAST_TIME: process.env.INTERVIEW_COMPLETED_PAST_TIME || 'PT4H', // The time before resource booking expiry when we should start sending notifications RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D', + // The match window for fetching post interview actions + POST_INTERVIEW_ACTION_MATCH_WINDOW: process.env.POST_INTERVIEW_ACTION_MATCH_WINDOW || 'P1D', // The Stripe STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY, CURRENCY: process.env.CURRENCY || 'usd', diff --git a/scripts/demo-email-notifications/index.js b/scripts/demo-email-notifications/index.js index 9a792b26..7e5b19c0 100644 --- a/scripts/demo-email-notifications/index.js +++ b/scripts/demo-email-notifications/index.js @@ -42,7 +42,11 @@ async function resetNotificationRecords () { const jobCandidate = await JobCandidate.findById('881a19de-2b0c-4bb9-b36a-4cb5e223bdb5') await jobCandidate.update({ status: 'interview' }) const c2Interview = await Interview.findById('077aa2ca-5b60-4ad9-a965-1b37e08a5046') - await c2Interview.update({ startTimestamp: completedStartTimestamp, duration, endTimestamp, guestNames: ['guest1', 'guest2'], hostName: 'hostName' }) + await c2Interview.update({ startTimestamp: moment().subtract(moment.duration(config.POST_INTERVIEW_ACTION_MATCH_WINDOW)).subtract(30, 'm').toDate(), duration, endTimestamp, guestNames: ['guest1', 'guest2'], hostName: 'hostName' }) + const jobCandidateWithinOneDay = await JobCandidate.findById('827ee401-df04-42e1-abbe-7b97ce7937ff') + await jobCandidateWithinOneDay.update({ status: 'interview' }) + const interviewWithinOneDay = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826') + await interviewWithinOneDay.update({ startTimestamp: completedStartTimestamp, duration, endTimestamp, guestNames: ['guest1', 'guest2'], hostName: 'hostName' }) // reset upcoming resource booking expiration records localLogger.info('reset upcoming resource booking expiration records') diff --git a/src/services/NotificationsSchedulerService.js b/src/services/NotificationsSchedulerService.js index 51c6d527..2e99efec 100644 --- a/src/services/NotificationsSchedulerService.js +++ b/src/services/NotificationsSchedulerService.js @@ -353,7 +353,10 @@ async function sendPostInterviewActionNotifications () { as: 'interviews', required: true, where: { - status: constants.Interviews.Status.Completed + status: constants.Interviews.Status.Completed, + startTimestamp: { + [Op.lte]: moment.utc().subtract(moment.duration(config.POST_INTERVIEW_ACTION_MATCH_WINDOW)) + } } }] })