Skip to content

Commit 9b13d56

Browse files
authored
Merge pull request #453 from tejad/dev
Adding support for generic duration format
2 parents 9ee4dab + 10845c4 commit 9b13d56

File tree

7 files changed

+179
-71
lines changed

7 files changed

+179
-71
lines changed

config/default.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ module.exports = {
244244
NOTIFICATION_SENDER_EMAIL: process.env.NOTIFICATION_SENDER_EMAIL,
245245
// the email notification sendgrid template id
246246
NOTIFICATION_SENDGRID_TEMPLATE_ID: process.env.NOTIFICATION_SENDGRID_TEMPLATE_ID,
247-
// hours after interview completed when we should post the notification
248-
INTERVIEW_COMPLETED_NOTIFICATION_HOURS: process.env.INTERVIEW_COMPLETED_NOTIFICATION_HOURS || 4,
249-
// no of weeks before expiry when we should post the notification
250-
RESOURCE_BOOKING_EXPIRY_NOTIFICATION_WEEKS: process.env.RESOURCE_BOOKING_EXPIRY_NOTIFICATION_WEEKS || 3,
251247
// frequency of cron checking for available candidates for review
252248
CRON_CANDIDATE_REVIEW: process.env.CRON_CANDIDATE_REVIEW || '00 00 13 * * 0-6',
253249
// frequency of cron checking for coming up interviews
@@ -259,5 +255,15 @@ module.exports = {
259255
// frequency of cron checking for post interview actions
260256
CRON_POST_INTERVIEW: process.env.CRON_POST_INTERVIEW || '00 00 13 * * 0-6',
261257
// frequency of cron checking for upcoming resource bookings
262-
CRON_UPCOMING_RESOURCE_BOOKING: process.env.CRON_UPCOMING_RESOURCE_BOOKING || '00 00 13 * * 1'
258+
CRON_UPCOMING_RESOURCE_BOOKING: process.env.CRON_UPCOMING_RESOURCE_BOOKING || '00 00 13 * * 1',
259+
// The match window for fetching interviews which are coming up
260+
INTERVIEW_COMING_UP_MATCH_WINDOW: process.env.INTERVIEW_COMING_UP_MATCH_WINDOW || 'PT5M',
261+
// The remind time for fetching interviews which are coming up
262+
INTERVIEW_COMING_UP_REMIND_TIME: (process.env.INTERVIEW_COMING_UP_REMIND_TIME || 'PT1H,PT24H').split(','),
263+
// The match window for fetching completed interviews
264+
INTERVIEW_COMPLETED_MATCH_WINDOW: process.env.INTERVIEW_COMPLETED_MATCH_WINDOW || 'PT5M',
265+
// The interview completed past time for fetching interviews
266+
INTERVIEW_COMPLETED_PAST_TIME: process.env.INTERVIEW_COMPLETED_PAST_TIME || 'PT4H',
267+
// The time before resource booking expiry when we should start sending notifications
268+
RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D'
263269
}

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",

package-lock.json

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"csv-parser": "^3.0.0",
7474
"handlebars": "^4.7.7",
7575
"mocha": "^8.1.3",
76+
"no-kafka": "^3.4.3",
7677
"nodemon": "^2.0.4",
7778
"nyc": "^15.1.0",
7879
"sequelize-cli": "^6.2.0",

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
/**

0 commit comments

Comments
 (0)