Skip to content

Commit 838df04

Browse files
committed
1 parent c37eab7 commit 838df04

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

config/default.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ module.exports = {
306306
// frequency of checking expired interview
307307
CRON_INTERVIEW_EXPIRED: process.env.CRON_INTERVIEW_EXPIRED || '*/5 * * * *',
308308
// frequency of checking interview schedule status which need remind job candidate to select time
309-
CRON_INTERVIEW_SCHEDULE_REMINDER: process.env.CRON_INTERVIEW_SCHEDULE_REMINDER || '00 00 13 * * 0-6',
309+
CRON_INTERVIEW_SCHEDULE_REMINDER: process.env.CRON_INTERVIEW_SCHEDULE_REMINDER || '*/5 * * * *',
310310
// frequency of cron checking for post interview actions
311311
CRON_POST_INTERVIEW: process.env.CRON_POST_INTERVIEW || '00 00 13 * * 0-6',
312312
// frequency of cron checking for upcoming resource bookings
@@ -315,6 +315,8 @@ module.exports = {
315315
INTERVIEW_COMING_UP_MATCH_WINDOW: process.env.INTERVIEW_COMING_UP_MATCH_WINDOW || 'PT5M',
316316
// The remind time for fetching interviews which are coming up
317317
INTERVIEW_COMING_UP_REMIND_TIME: (process.env.INTERVIEW_COMING_UP_REMIND_TIME || 'PT1H,PT24H').split(','),
318+
// The match window for fetching schedule reminder interviews
319+
INTERVIEW_SCHEDULE_REMINDER_WINDOW: process.env.INTERVIEW_SCHEDULE_REMINDER_WINDOW || 'PT5M',
318320
// The match window for fetching completed interviews
319321
INTERVIEW_COMPLETED_MATCH_WINDOW: process.env.INTERVIEW_COMPLETED_MATCH_WINDOW || 'PT5M',
320322
// The interview completed past time for fetching interviews

src/services/NotificationsSchedulerService.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ async function sendInterviewScheduleReminderNotifications () {
596596

597597
localLogger.debug('[sendInterviewScheduleReminderNotifications]: Looking for due records...')
598598
const currentTime = moment.utc()
599-
const compareTime = currentTime.add(-INTERVIEW_REMINDER_DAY_AFTER).add(1, 'days').startOf('day')
599+
const compareTime = currentTime.clone().subtract(moment.duration(INTERVIEW_REMINDER_DAY_AFTER)).endOf('day')
600600

601601
const timestampFilter = {
602602
[Op.and]: [
@@ -631,25 +631,28 @@ async function sendInterviewScheduleReminderNotifications () {
631631
let interviewCount = 0
632632
for (const interview of interviews) {
633633
const start = moment(interview.createdAt)
634-
if (currentTime.subtract(INTERVIEW_REMINDER_DAY_AFTER).diff(start, 'days') % INTERVIEW_REMINDER_FREQUENCY === 0) {
635-
// sendEmail
636-
const data = await getDataForInterview(interview)
637-
if (!data) { continue }
638-
639-
if (!_.isEmpty(data.guestEmail)) {
640-
// send guest emails
641-
sendNotification({}, {
642-
template,
643-
recipients: [{ email: data.guestEmail }],
644-
data: {
645-
...data,
646-
subject: `Reminder: ${data.duration} minutes tech interview with ${data.guestFullName} for ${data.jobTitle} is requested by the Customer`
647-
}
648-
})
649-
} else {
650-
localLogger.error(`Interview id: ${interview.id} guest emails not present`, 'sendInterviewScheduleReminderNotifications')
634+
if (currentTime.clone().subtract(INTERVIEW_REMINDER_DAY_AFTER).diff(start, 'days') % INTERVIEW_REMINDER_FREQUENCY === 0) {
635+
const minutesInterval = currentTime.clone().diff(start, 'minutes') % (60 * 24)
636+
if (minutesInterval < moment.duration(config.INTERVIEW_SCHEDULE_REMINDER_WINDOW).minutes()) {
637+
// sendEmail
638+
const data = await getDataForInterview(interview)
639+
if (!data) { continue }
640+
641+
if (!_.isEmpty(data.guestEmail)) {
642+
// send guest emails
643+
sendNotification({}, {
644+
template,
645+
recipients: [{ email: data.guestEmail }],
646+
data: {
647+
...data,
648+
subject: `Reminder: ${data.duration} minutes tech interview with ${data.guestFullName} for ${data.jobTitle} is requested by the Customer`
649+
}
650+
})
651+
} else {
652+
localLogger.error(`Interview id: ${interview.id} guest emails not present`, 'sendInterviewScheduleReminderNotifications')
653+
}
654+
interviewCount++
651655
}
652-
interviewCount++
653656
}
654657
}
655658

0 commit comments

Comments
 (0)