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
6 changes: 4 additions & 2 deletions scripts/demo-email-notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ async function resetNotificationRecords () {

// 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')
const jobCandidate = await JobCandidate.findById('827ee401-df04-42e1-abbe-7b97ce7937ff')
await jobCandidate.update({ status: 'interview' })
const c2Interview = await Interview.findById('077aa2ca-5b60-4ad9-a965-1b37e08a5046')
const c2Interview = await Interview.findById('3144fa65-ea1a-4bec-81b0-7cb1c8845826')
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 c2InterviewR2 = await Interview.findById('b1f7ba76-640f-47e2-9463-59e51b51ec60')
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' })

// reset upcoming resource booking expiration records
localLogger.info('reset upcoming resource booking expiration records')
Expand Down
44 changes: 22 additions & 22 deletions src/services/NotificationsSchedulerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,11 @@ async function sendInterviewCompletedNotifications () {
]
}

const interviews = await Interview.findAll({
let interviews = await Interview.findAll({
where: filter,
raw: true
})
interviews = _.map(_.values(_.groupBy(interviews, 'jobCandidateId')), (interviews) => _.maxBy(interviews, 'round'))

const jobCandidates = await JobCandidate.findAll({ where: { id: _.map(interviews, 'jobCandidateId') } })
const jcMap = _.keyBy(jobCandidates, 'id')
Expand Down Expand Up @@ -418,28 +419,27 @@ async function sendPostInterviewActionNotifications () {
const projectJcs = _.filter(completedJobCandidates, jc => jc.jobId === projectJob.id)
numCandidates += projectJcs.length
for (const projectJc of projectJcs) {
for (const interview of projectJc.interviews) {
const d = await getDataForInterview(interview, projectJc, projectJob)
if (!d) { continue }
d.jobUrl = `${config.TAAS_APP_URL}/${projectId}/positions/${projectJob.id}`
webNotifications.push({
serviceId: 'web',
type: template,
details: {
recipients: projectTeamRecipients,
contents: {
jobTitle: d.jobTitle,
teamName: project.name,
projectId,
jobId: projectJob.id,
userHandle: d.handle
},
version: 1
}
})
const interview = _.maxBy(projectJc.interviews, 'round')
const d = await getDataForInterview(interview, projectJc, projectJob)
if (!d) { continue }
d.jobUrl = `${config.TAAS_APP_URL}/${projectId}/positions/${projectJob.id}`
webNotifications.push({
serviceId: 'web',
type: template,
details: {
recipients: projectTeamRecipients,
contents: {
jobTitle: d.jobTitle,
teamName: project.name,
projectId,
jobId: projectJob.id,
userHandle: d.handle
},
version: 1
}
})

teamInterviews.push(d)
}
teamInterviews.push(d)
}
}

Expand Down