Skip to content

Commit 3d7022e

Browse files
committed
Making sure all email notifications are coming through demo script
1 parent 4593901 commit 3d7022e

File tree

4 files changed

+26
-29
lines changed

4 files changed

+26
-29
lines changed

data/demo-data.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,9 @@
859859
"startTimestamp": null,
860860
"endTimestamp": null,
861861
"hostName": null,
862-
"hostEmail": null,
863-
"guestNames": null,
864-
"guestEmails": null,
862+
"hostEmail": "[email protected]",
863+
"guestNames": ["guest name1", "guest name2"],
864+
"guestEmails": ["[email protected]", "[email protected]"],
865865
"status": "Completed",
866866
"rescheduleUrl": null,
867867
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
@@ -900,9 +900,9 @@
900900
"startTimestamp": null,
901901
"endTimestamp": null,
902902
"hostName": null,
903-
"hostEmail": null,
904-
"guestNames": null,
905-
"guestEmails": null,
903+
"hostEmail": "[email protected]",
904+
"guestNames": ["guest name1", "guest name2"],
905+
"guestEmails": ["[email protected]", "[email protected]"],
906906
"status": "Scheduling",
907907
"rescheduleUrl": null,
908908
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
@@ -926,9 +926,9 @@
926926
"startTimestamp": null,
927927
"endTimestamp": null,
928928
"hostName": null,
929-
"hostEmail": null,
930-
"guestNames": null,
931-
"guestEmails": null,
929+
"hostEmail": "[email protected]",
930+
"guestNames": ["guest name1", "guest name2"],
931+
"guestEmails": ["[email protected]", "[email protected]"],
932932
"status": "Completed",
933933
"rescheduleUrl": null,
934934
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
@@ -967,9 +967,9 @@
967967
"startTimestamp": null,
968968
"endTimestamp": null,
969969
"hostName": null,
970-
"hostEmail": null,
971-
"guestNames": null,
972-
"guestEmails": null,
970+
"hostEmail": "[email protected]",
971+
"guestNames": ["guest name1", "guest name2"],
972+
"guestEmails": ["[email protected]", "[email protected]"],
973973
"status": "Scheduling",
974974
"rescheduleUrl": null,
975975
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
@@ -993,9 +993,9 @@
993993
"startTimestamp": null,
994994
"endTimestamp": null,
995995
"hostName": null,
996-
"hostEmail": null,
997-
"guestNames": null,
998-
"guestEmails": null,
996+
"hostEmail": "[email protected]",
997+
"guestNames": ["guest name1", "guest name2"],
998+
"guestEmails": ["[email protected]", "[email protected]"],
999999
"status": "Scheduling",
10001000
"rescheduleUrl": null,
10011001
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
@@ -1019,9 +1019,9 @@
10191019
"startTimestamp": null,
10201020
"endTimestamp": null,
10211021
"hostName": null,
1022-
"hostEmail": null,
1023-
"guestNames": null,
1024-
"guestEmails": null,
1022+
"hostEmail": "[email protected]",
1023+
"guestNames": ["guest name1", "guest name2"],
1024+
"guestEmails": ["[email protected]", "[email protected]"],
10251025
"status": "Completed",
10261026
"rescheduleUrl": null,
10271027
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",

scripts/demo-email-notifications/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This script does 2 things:
1515
CRON_INTERVIEW_COMPLETED=0 */1 * * * *
1616
CRON_POST_INTERVIEW=0 */1 * * * *
1717
CRON_UPCOMING_RESOURCE_BOOKING=0 */1 * * * *
18+
INTERVIEW_COMING_UP_MATCH_WINDOW=PT1M
19+
INTERVIEW_COMPLETED_MATCH_WINDOW=PT1M
1820
```
1921

2022
2. Recreate demo data by:
@@ -34,4 +36,4 @@ This script does 2 things:
3436
node scripts/demo-email-notifications
3537
```
3638

37-
Check the rendered emails inside `out` folder.
39+
Check the rendered emails inside `out` folder.

scripts/demo-email-notifications/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ async function resetNotificationRecords () {
2323
// reset coming up interview records
2424
localLogger.info('reset coming up interview records')
2525
const interview = await Interview.findById('976d23a9-5710-453f-99d9-f57a588bb610')
26-
const startTimestamp = moment().add(moment.duration('PT1H')).add('PT1M').toDate()
26+
const startTimestamp = moment().add(moment.duration(config.INTERVIEW_COMING_UP_REMIND_TIME[0])).add(config.INTERVIEW_COMING_UP_MATCH_WINDOW).toDate()
2727
await interview.update({ startTimestamp, duration: 30, status: Interviews.Status.Scheduled, guestNames: ['test1', 'test2'], hostName: 'hostName' })
2828

2929
// reset completed interview records
3030
localLogger.info('reset completed interview records')
31-
const pastTime = moment.duration('PT1H')
32-
const endTimestamp = moment().subtract(pastTime).toDate()
31+
const pastTime = moment.duration(config.INTERVIEW_COMPLETED_PAST_TIME)
32+
const endTimestamp = moment().subtract(pastTime).add(config.INTERVIEW_COMPLETED_MATCH_WINDOW).toDate()
3333
const completedInterview = await Interview.findById('9efd72c3-1dc7-4ce2-9869-8cca81d0adeb')
3434
const duration = 30
3535
const completedStartTimestamp = moment().subtract(pastTime).subtract(30, 'm').toDate()
@@ -45,7 +45,8 @@ async function resetNotificationRecords () {
4545
// reset upcoming resource booking expiration records
4646
localLogger.info('reset upcoming resource booking expiration records')
4747
const resourceBooking = await ResourceBooking.findById('62c3f0c9-2bf0-4f24-8647-2c802a39cbcb')
48-
await resourceBooking.update({ endDate: moment().add(1, 'weeks').toDate() })
48+
const testEnd = moment().add(moment.duration(config.RESOURCE_BOOKING_EXPIRY_TIME)).toDate()
49+
await resourceBooking.update({ endDate: testEnd })
4950
}
5051

5152
/**

src/services/EmailNotificationService.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ async function sendCandidatesAvailableEmails () {
126126
if (!project) { continue }
127127

128128
const recipientEmails = getProjectMembersEmails(project)
129-
if (_.isEmpty(recipientEmails)) { continue }
130-
131129
const projectJobs = _.filter(jobs, job => job.projectId === projectId)
132130

133131
const teamJobs = []
@@ -348,8 +346,6 @@ async function sendPostInterviewActionEmails () {
348346
if (!project) { continue }
349347

350348
const recipientEmails = getProjectMembersEmails(project)
351-
if (_.isEmpty(recipientEmails)) { continue }
352-
353349
const projectJobs = _.filter(jobs, job => job.projectId === projectId)
354350
const teamInterviews = []
355351
let numCandidates = 0
@@ -418,8 +414,6 @@ async function sendResourceBookingExpirationEmails () {
418414
const project = await getProjectWithId(projectId)
419415
if (!project) { continue }
420416
const recipientEmails = getProjectMembersEmails(project)
421-
if (_.isEmpty(recipientEmails)) { continue }
422-
423417
const projectJobs = _.filter(jobs, job => job.projectId === projectId)
424418

425419
let numResourceBookings = 0

0 commit comments

Comments
 (0)