Skip to content

Commit 3c04b80

Browse files
authored
Merge pull request #545 from xxcxy/fix-issues-541
Interview completed email notification should not be sent
2 parents 003fdc4 + cf8f6fe commit 3c04b80

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

scripts/demo-email-notifications/index.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,15 @@ async function resetNotificationRecords () {
3636
const duration = 30
3737
const completedEndTimestamp = moment(completedStartTimestamp).clone().add(30, 'm').toDate()
3838
await completedInterview.update({ startTimestamp: completedStartTimestamp, duration, endTimeStamp: completedEndTimestamp, status: Interviews.Status.Scheduled, guestNames: ['guest1', 'guest2'], hostName: 'hostName' })
39+
const completedInterview2 = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826')
40+
await completedInterview2.update({ startTimestamp: completedStartTimestamp, duration, endTimeStamp: completedEndTimestamp, status: Interviews.Status.Scheduled, guestNames: ['guest1', 'guest2'], hostName: 'hostName' })
3941

4042
// reset post interview candidate action reminder records
4143
localLogger.info('reset post interview candidate action reminder records')
4244
const jobCandidate = await JobCandidate.findById('881a19de-2b0c-4bb9-b36a-4cb5e223bdb5')
4345
await jobCandidate.update({ status: 'interview' })
4446
const c2Interview = await Interview.findById('077aa2ca-5b60-4ad9-a965-1b37e08a5046')
4547
await c2Interview.update({ startTimestamp: moment().subtract(moment.duration(config.POST_INTERVIEW_ACTION_MATCH_WINDOW)).subtract(30, 'm').toDate(), duration, endTimeStamp: completedEndTimestamp, guestNames: ['guest1', 'guest2'], hostName: 'hostName' })
46-
const jobCandidateWithinOneDay = await JobCandidate.findById('827ee401-df04-42e1-abbe-7b97ce7937ff')
47-
await jobCandidateWithinOneDay.update({ status: 'interview' })
48-
const interviewWithinOneDay = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826')
49-
await interviewWithinOneDay.update({
50-
startTimestamp: moment(completedStartTimestamp).clone().add(config.INTERVIEW_COMPLETED_MATCH_WINDOW), // add WINDOW to not receive "completed interview" email
51-
duration,
52-
endTimeStamp: moment(completedEndTimestamp).clone().add(config.INTERVIEW_COMPLETED_MATCH_WINDOW), // add WINDOW to not receive "completed interview" email
53-
guestNames: ['guest1', 'guest2'],
54-
hostName: 'hostName'
55-
})
5648

5749
// reset upcoming resource booking expiration records
5850
localLogger.info('reset upcoming resource booking expiration records')

src/services/NotificationsSchedulerService.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ async function sendInterviewCompletedNotifications () {
323323
raw: true
324324
})
325325

326+
const jobCandidates = await JobCandidate.findAll({ where: { id: _.map(interviews, 'jobCandidateId') } })
327+
const jcMap = _.keyBy(jobCandidates, 'id')
328+
326329
localLogger.debug(`[sendInterviewCompletedNotifications]: Found ${interviews.length} interviews which must be ended by now.`)
327330

328331
let sentCount = 0
@@ -331,8 +334,12 @@ async function sendInterviewCompletedNotifications () {
331334
localLogger.error(`Interview id: ${interview.id} host email not present`)
332335
continue
333336
}
337+
if (!jcMap[interview.jobCandidateId] || jcMap[interview.jobCandidateId].status !== constants.JobCandidateStatus.INTERVIEW) {
338+
localLogger.error(`Interview id: ${interview.id} job candidate status is not ${constants.JobCandidateStatus.INTERVIEW}`)
339+
continue
340+
}
334341

335-
const data = await getDataForInterview(interview)
342+
const data = await getDataForInterview(interview, jcMap[interview.jobCandidateId])
336343
if (!data) { continue }
337344

338345
sendNotification({}, {

0 commit comments

Comments
 (0)