Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions scripts/demo-email-notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,15 @@ async function resetNotificationRecords () {
const duration = 30
const completedEndTimestamp = moment(completedStartTimestamp).clone().add(30, 'm').toDate()
await completedInterview.update({ startTimestamp: completedStartTimestamp, duration, endTimeStamp: completedEndTimestamp, status: Interviews.Status.Scheduled, guestNames: ['guest1', 'guest2'], hostName: 'hostName' })
const completedInterview2 = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826')
await completedInterview2.update({ startTimestamp: completedStartTimestamp, duration, endTimeStamp: completedEndTimestamp, status: Interviews.Status.Scheduled, guestNames: ['guest1', 'guest2'], hostName: 'hostName' })

// reset post interview candidate action reminder records
localLogger.info('reset post interview candidate action reminder records')
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: moment().subtract(moment.duration(config.POST_INTERVIEW_ACTION_MATCH_WINDOW)).subtract(30, 'm').toDate(), duration, endTimeStamp: completedEndTimestamp, 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: moment(completedStartTimestamp).clone().add(config.INTERVIEW_COMPLETED_MATCH_WINDOW), // add WINDOW to not receive "completed interview" email
duration,
endTimeStamp: moment(completedEndTimestamp).clone().add(config.INTERVIEW_COMPLETED_MATCH_WINDOW), // add WINDOW to not receive "completed interview" email
guestNames: ['guest1', 'guest2'],
hostName: 'hostName'
})

// reset upcoming resource booking expiration records
localLogger.info('reset upcoming resource booking expiration records')
Expand Down
9 changes: 8 additions & 1 deletion src/services/NotificationsSchedulerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ async function sendInterviewCompletedNotifications () {
raw: true
})

const jobCandidates = await JobCandidate.findAll({ where: { id: _.map(interviews, 'jobCandidateId') } })
const jcMap = _.keyBy(jobCandidates, 'id')

localLogger.debug(`[sendInterviewCompletedNotifications]: Found ${interviews.length} interviews which must be ended by now.`)

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

const data = await getDataForInterview(interview)
const data = await getDataForInterview(interview, jcMap[interview.jobCandidateId])
if (!data) { continue }

sendNotification({}, {
Expand Down