Skip to content

Commit 5f47181

Browse files
authored
Merge pull request #547 from xxcxy/fix-issues-540
fix Issues with Post Interview Action Reminder email notification
2 parents 3c04b80 + 9ace73e commit 5f47181

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

scripts/demo-email-notifications/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ async function resetNotificationRecords () {
4141

4242
// reset post interview candidate action reminder records
4343
localLogger.info('reset post interview candidate action reminder records')
44-
const jobCandidate = await JobCandidate.findById('881a19de-2b0c-4bb9-b36a-4cb5e223bdb5')
44+
const jobCandidate = await JobCandidate.findById('827ee401-df04-42e1-abbe-7b97ce7937ff')
4545
await jobCandidate.update({ status: 'interview' })
46-
const c2Interview = await Interview.findById('077aa2ca-5b60-4ad9-a965-1b37e08a5046')
46+
const c2Interview = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826')
4747
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' })
48+
const c2InterviewR2 = await Interview.findById('b1f7ba76-640f-47e2-9463-59e51b51ec60')
49+
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' })
4850

4951
// reset upcoming resource booking expiration records
5052
localLogger.info('reset upcoming resource booking expiration records')

src/services/NotificationsSchedulerService.js

+22-22
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
const jobCandidates = await JobCandidate.findAll({ where: { id: _.map(interviews, 'jobCandidateId') } })
327328
const jcMap = _.keyBy(jobCandidates, 'id')
@@ -418,28 +419,27 @@ async function sendPostInterviewActionNotifications () {
418419
const projectJcs = _.filter(completedJobCandidates, jc => jc.jobId === projectJob.id)
419420
numCandidates += projectJcs.length
420421
for (const projectJc of projectJcs) {
421-
for (const interview of projectJc.interviews) {
422-
const d = await getDataForInterview(interview, projectJc, projectJob)
423-
if (!d) { continue }
424-
d.jobUrl = `${config.TAAS_APP_URL}/${projectId}/positions/${projectJob.id}`
425-
webNotifications.push({
426-
serviceId: 'web',
427-
type: template,
428-
details: {
429-
recipients: projectTeamRecipients,
430-
contents: {
431-
jobTitle: d.jobTitle,
432-
teamName: project.name,
433-
projectId,
434-
jobId: projectJob.id,
435-
userHandle: d.handle
436-
},
437-
version: 1
438-
}
439-
})
422+
const interview = _.maxBy(projectJc.interviews, 'round')
423+
const d = await getDataForInterview(interview, projectJc, projectJob)
424+
if (!d) { continue }
425+
d.jobUrl = `${config.TAAS_APP_URL}/${projectId}/positions/${projectJob.id}`
426+
webNotifications.push({
427+
serviceId: 'web',
428+
type: template,
429+
details: {
430+
recipients: projectTeamRecipients,
431+
contents: {
432+
jobTitle: d.jobTitle,
433+
teamName: project.name,
434+
projectId,
435+
jobId: projectJob.id,
436+
userHandle: d.handle
437+
},
438+
version: 1
439+
}
440+
})
440441

441-
teamInterviews.push(d)
442-
}
442+
teamInterviews.push(d)
443443
}
444444
}
445445

0 commit comments

Comments
 (0)