Skip to content

Commit ae96099

Browse files
committed
fix Issues with Post Interview Action Reminder email notification when interview 2 is scheduled
1 parent 7b95462 commit ae96099

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

scripts/demo-email-notifications/index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,12 @@ async function resetNotificationRecords () {
3939

4040
// reset post interview candidate action reminder records
4141
localLogger.info('reset post interview candidate action reminder records')
42-
const jobCandidate = await JobCandidate.findById('881a19de-2b0c-4bb9-b36a-4cb5e223bdb5')
42+
const jobCandidate = await JobCandidate.findById('827ee401-df04-42e1-abbe-7b97ce7937ff')
4343
await jobCandidate.update({ status: 'interview' })
44-
const c2Interview = await Interview.findById('077aa2ca-5b60-4ad9-a965-1b37e08a5046')
44+
const c2Interview = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826')
4545
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-
})
46+
const c2InterviewR2 = await Interview.findById('b1f7ba76-640f-47e2-9463-59e51b51ec60')
47+
await c2InterviewR2.update({ status: 'Scheduled', startTimestamp: moment().subtract(moment.duration(config.POST_INTERVIEW_ACTION_MATCH_WINDOW)).subtract(30, 'm').toDate(), duration, endTimeStamp: completedEndTimestamp, guestNames: ['guest1', 'guest2'], hostName: 'hostName' })
5648

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

src/services/NotificationsSchedulerService.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,11 @@ async function sendInterviewCompletedNotifications () {
318318
]
319319
}
320320

321-
const interviews = await Interview.findAll({
321+
let interviews = await Interview.findAll({
322322
where: filter,
323323
raw: true
324324
})
325+
interviews = _.map(_.values(_.groupBy(interviews, 'jobCandidateId')), (interviews) => _.maxBy(interviews, 'round'))
325326

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

@@ -411,28 +412,27 @@ async function sendPostInterviewActionNotifications () {
411412
const projectJcs = _.filter(completedJobCandidates, jc => jc.jobId === projectJob.id)
412413
numCandidates += projectJcs.length
413414
for (const projectJc of projectJcs) {
414-
for (const interview of projectJc.interviews) {
415-
const d = await getDataForInterview(interview, projectJc, projectJob)
416-
if (!d) { continue }
417-
d.jobUrl = `${config.TAAS_APP_URL}/${projectId}/positions/${projectJob.id}`
418-
webNotifications.push({
419-
serviceId: 'web',
420-
type: template,
421-
details: {
422-
recipients: projectTeamRecipients,
423-
contents: {
424-
jobTitle: d.jobTitle,
425-
teamName: project.name,
426-
projectId,
427-
jobId: projectJob.id,
428-
userHandle: d.handle
429-
},
430-
version: 1
431-
}
432-
})
415+
const interview = _.maxBy(projectJc.interviews, 'round')
416+
const d = await getDataForInterview(interview, projectJc, projectJob)
417+
if (!d) { continue }
418+
d.jobUrl = `${config.TAAS_APP_URL}/${projectId}/positions/${projectJob.id}`
419+
webNotifications.push({
420+
serviceId: 'web',
421+
type: template,
422+
details: {
423+
recipients: projectTeamRecipients,
424+
contents: {
425+
jobTitle: d.jobTitle,
426+
teamName: project.name,
427+
projectId,
428+
jobId: projectJob.id,
429+
userHandle: d.handle
430+
},
431+
version: 1
432+
}
433+
})
433434

434-
teamInterviews.push(d)
435-
}
435+
teamInterviews.push(d)
436436
}
437437
}
438438

0 commit comments

Comments
 (0)