Skip to content

Interview completed email notification should not be sent #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions scripts/demo-email-notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ 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')
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