Skip to content

Commit 61c2cc8

Browse files
committed
improved logs for email notifications
1 parent d7f27b2 commit 61c2cc8

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/services/EmailNotificationService.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ async function sendCandidatesAvailableEmails () {
121121

122122
const projectIds = _.uniq(_.map(jobs, job => job.projectId))
123123

124-
localLogger.debug(`[sendCandidatesAvailableEmails]: Found ${projectIds.length} project with Job Candidates awaiting for review.`)
124+
localLogger.debug(`[sendCandidatesAvailableEmails]: Found ${projectIds.length} projects with Job Candidates awaiting for review.`)
125125

126126
// for each unique project id, send an email
127+
let sentCount = 0
127128
for (const projectId of projectIds) {
128129
const project = await getProjectWithId(projectId)
129130
if (!project) { continue }
@@ -175,7 +176,10 @@ async function sendCandidatesAvailableEmails () {
175176
description: 'Candidates are available for review'
176177
}
177178
})
179+
180+
sentCount++
178181
}
182+
localLogger.debug(`[sendCandidatesAvailableEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Job Candidates awaiting for review.`)
179183
}
180184

181185
/**
@@ -219,8 +223,10 @@ async function sendInterviewComingUpEmails () {
219223
raw: true
220224
})
221225

222-
localLogger.debug(`[sendInterviewComingUpEmails]: Found ${interviews.length} Interviews which are coming soon.`)
226+
localLogger.debug(`[sendInterviewComingUpEmails]: Found ${interviews.length} interviews which are coming soon.`)
223227

228+
let sentHostCount = 0
229+
let sentGuestCount = 0
224230
for (const interview of interviews) {
225231
// send host email
226232
const data = await getDataForInterview(interview)
@@ -238,6 +244,8 @@ async function sendInterviewComingUpEmails () {
238244
description: 'Interview Coming Up'
239245
}
240246
})
247+
248+
sentHostCount++
241249
} else {
242250
localLogger.error(`Interview id: ${interview.id} host email not present`, 'sendInterviewComingUpEmails')
243251
}
@@ -255,10 +263,14 @@ async function sendInterviewComingUpEmails () {
255263
description: 'Interview Coming Up'
256264
}
257265
})
266+
267+
sentGuestCount++
258268
} else {
259269
localLogger.error(`Interview id: ${interview.id} guest emails not present`, 'sendInterviewComingUpEmails')
260270
}
261271
}
272+
273+
localLogger.debug(`[sendInterviewComingUpEmails]: Sent notifications for ${sentHostCount} hosts and ${sentGuestCount} guest of ${interviews.length} interviews which are coming soon.`)
262274
}
263275

264276
/**
@@ -293,8 +305,9 @@ async function sendInterviewCompletedEmails () {
293305
raw: true
294306
})
295307

296-
localLogger.debug(`[sendInterviewCompletedEmails]: Found ${interviews.length} Interviews which must be ended by now.`)
308+
localLogger.debug(`[sendInterviewCompletedEmails]: Found ${interviews.length} interviews which must be ended by now.`)
297309

310+
let sentCount = 0
298311
for (const interview of interviews) {
299312
if (_.isEmpty(interview.hostEmail)) {
300313
localLogger.error(`Interview id: ${interview.id} host email not present`)
@@ -315,7 +328,11 @@ async function sendInterviewCompletedEmails () {
315328
description: 'Interview Completed'
316329
}
317330
})
331+
332+
sentCount++
318333
}
334+
335+
localLogger.debug(`[sendInterviewCompletedEmails]: Sent notifications for ${sentCount} of ${interviews.length} interviews which must be ended by now.`)
319336
}
320337

321338
/**
@@ -337,8 +354,6 @@ async function sendPostInterviewActionEmails () {
337354
}]
338355
})
339356

340-
localLogger.debug(`[sendPostInterviewActionEmails]: Found ${completedJobCandidates.length} Job Candidates with interview completed awaiting for an action.`)
341-
342357
// get all project ids for this job candidates
343358
const jobs = await Job.findAll({
344359
where: {
@@ -350,6 +365,10 @@ async function sendPostInterviewActionEmails () {
350365
})
351366

352367
const projectIds = _.uniq(_.map(jobs, job => job.projectId))
368+
369+
localLogger.debug(`[sendPostInterviewActionEmails]: Found ${projectIds.length} projects with ${completedJobCandidates.length} Job Candidates with interview completed awaiting for an action.`)
370+
371+
let sentCount = 0
353372
for (const projectId of projectIds) {
354373
const project = await getProjectWithId(projectId)
355374
if (!project) { continue }
@@ -383,7 +402,11 @@ async function sendPostInterviewActionEmails () {
383402
description: 'Post Interview Candidate Action Reminder'
384403
}
385404
})
405+
406+
sentCount++
386407
}
408+
409+
localLogger.debug(`[sendPostInterviewActionEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Job Candidates with interview completed awaiting for an action.`)
387410
}
388411

389412
/**
@@ -419,8 +442,9 @@ async function sendResourceBookingExpirationEmails () {
419442
})
420443
const projectIds = _.uniq(_.map(expiringResourceBookings, rb => rb.projectId))
421444

422-
localLogger.debug(`[sendResourceBookingExpirationEmails]: Found ${projectIds.length} project with ${expiringResourceBookings.length} Resource Bookings expiring in less than 3 weeks.`)
445+
localLogger.debug(`[sendResourceBookingExpirationEmails]: Found ${projectIds.length} projects with ${expiringResourceBookings.length} Resource Bookings expiring in less than 3 weeks.`)
423446

447+
let sentCount = 0
424448
for (const projectId of projectIds) {
425449
const project = await getProjectWithId(projectId)
426450
if (!project) { continue }
@@ -458,7 +482,11 @@ async function sendResourceBookingExpirationEmails () {
458482
description: 'Upcoming Resource Booking Expiration'
459483
}
460484
})
485+
486+
sentCount++
461487
}
488+
489+
localLogger.debug(`[sendResourceBookingExpirationEmails]: Sent notifications for ${sentCount} of ${projectIds.length} projects with Resource Bookings expiring in less than 3 weeks.`)
462490
}
463491

464492
/**

0 commit comments

Comments
 (0)