Skip to content

Adding support for generic duration format #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2021
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
16 changes: 11 additions & 5 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ module.exports = {
NOTIFICATION_SENDER_EMAIL: process.env.NOTIFICATION_SENDER_EMAIL,
// the email notification sendgrid template id
NOTIFICATION_SENDGRID_TEMPLATE_ID: process.env.NOTIFICATION_SENDGRID_TEMPLATE_ID,
// hours after interview completed when we should post the notification
INTERVIEW_COMPLETED_NOTIFICATION_HOURS: process.env.INTERVIEW_COMPLETED_NOTIFICATION_HOURS || 4,
// no of weeks before expiry when we should post the notification
RESOURCE_BOOKING_EXPIRY_NOTIFICATION_WEEKS: process.env.RESOURCE_BOOKING_EXPIRY_NOTIFICATION_WEEKS || 3,
// frequency of cron checking for available candidates for review
CRON_CANDIDATE_REVIEW: process.env.CRON_CANDIDATE_REVIEW || '00 00 13 * * 0-6',
// frequency of cron checking for coming up interviews
Expand All @@ -259,5 +255,15 @@ module.exports = {
// frequency of cron checking for post interview actions
CRON_POST_INTERVIEW: process.env.CRON_POST_INTERVIEW || '00 00 13 * * 0-6',
// frequency of cron checking for upcoming resource bookings
CRON_UPCOMING_RESOURCE_BOOKING: process.env.CRON_UPCOMING_RESOURCE_BOOKING || '00 00 13 * * 1'
CRON_UPCOMING_RESOURCE_BOOKING: process.env.CRON_UPCOMING_RESOURCE_BOOKING || '00 00 13 * * 1',
// The match window for fetching interviews which are coming up
INTERVIEW_COMING_UP_MATCH_WINDOW: process.env.INTERVIEW_COMING_UP_MATCH_WINDOW || 'PT5M',
// The remind time for fetching interviews which are coming up
INTERVIEW_COMING_UP_REMIND_TIME: (process.env.INTERVIEW_COMING_UP_REMIND_TIME || 'PT1H,PT24H').split(','),
// The match window for fetching completed interviews
INTERVIEW_COMPLETED_MATCH_WINDOW: process.env.INTERVIEW_COMPLETED_MATCH_WINDOW || 'PT5M',
// The interview completed past time for fetching interviews
INTERVIEW_COMPLETED_PAST_TIME: process.env.INTERVIEW_COMPLETED_PAST_TIME || 'PT4H',
// The time before resource booking expiry when we should start sending notifications
RESOURCE_BOOKING_EXPIRY_TIME: process.env.RESOURCE_BOOKING_EXPIRY_TIME || 'P21D'
}
36 changes: 18 additions & 18 deletions data/demo-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,9 @@
"startTimestamp": null,
"endTimestamp": null,
"hostName": null,
"hostEmail": null,
"guestNames": null,
"guestEmails": null,
"hostEmail": "interviewhost@tc.com",
"guestNames": ["guest name1", "guest name2"],
"guestEmails": ["guest1@tc.com", "guest2@tc.com"],
"status": "Completed",
"rescheduleUrl": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand Down Expand Up @@ -900,9 +900,9 @@
"startTimestamp": null,
"endTimestamp": null,
"hostName": null,
"hostEmail": null,
"guestNames": null,
"guestEmails": null,
"hostEmail": "interviewhost@tc.com",
"guestNames": ["guest name1", "guest name2"],
"guestEmails": ["guest1@tc.com", "guest2@tc.com"],
"status": "Scheduling",
"rescheduleUrl": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand All @@ -926,9 +926,9 @@
"startTimestamp": null,
"endTimestamp": null,
"hostName": null,
"hostEmail": null,
"guestNames": null,
"guestEmails": null,
"hostEmail": "interviewhost@tc.com",
"guestNames": ["guest name1", "guest name2"],
"guestEmails": ["guest1@tc.com", "guest2@tc.com"],
"status": "Completed",
"rescheduleUrl": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand Down Expand Up @@ -967,9 +967,9 @@
"startTimestamp": null,
"endTimestamp": null,
"hostName": null,
"hostEmail": null,
"guestNames": null,
"guestEmails": null,
"hostEmail": "interviewhost@tc.com",
"guestNames": ["guest name1", "guest name2"],
"guestEmails": ["guest1@tc.com", "guest2@tc.com"],
"status": "Scheduling",
"rescheduleUrl": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand All @@ -993,9 +993,9 @@
"startTimestamp": null,
"endTimestamp": null,
"hostName": null,
"hostEmail": null,
"guestNames": null,
"guestEmails": null,
"hostEmail": "interviewhost@tc.com",
"guestNames": ["guest name1", "guest name2"],
"guestEmails": ["guest1@tc.com", "guest2@tc.com"],
"status": "Scheduling",
"rescheduleUrl": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand All @@ -1019,9 +1019,9 @@
"startTimestamp": null,
"endTimestamp": null,
"hostName": null,
"hostEmail": null,
"guestNames": null,
"guestEmails": null,
"hostEmail": "interviewhost@tc.com",
"guestNames": ["guest name1", "guest name2"],
"guestEmails": ["guest1@tc.com", "guest2@tc.com"],
"status": "Completed",
"rescheduleUrl": null,
"createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
Expand Down
113 changes: 113 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"csv-parser": "^3.0.0",
"handlebars": "^4.7.7",
"mocha": "^8.1.3",
"no-kafka": "^3.4.3",
"nodemon": "^2.0.4",
"nyc": "^15.1.0",
"sequelize-cli": "^6.2.0",
Expand Down
4 changes: 3 additions & 1 deletion scripts/demo-email-notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ This script does 2 things:
CRON_INTERVIEW_COMPLETED=0 */1 * * * *
CRON_POST_INTERVIEW=0 */1 * * * *
CRON_UPCOMING_RESOURCE_BOOKING=0 */1 * * * *
INTERVIEW_COMING_UP_MATCH_WINDOW=PT1M
INTERVIEW_COMPLETED_MATCH_WINDOW=PT1M
```

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

Check the rendered emails inside `out` folder.
Check the rendered emails inside `out` folder.
9 changes: 5 additions & 4 deletions scripts/demo-email-notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ async function resetNotificationRecords () {
// reset coming up interview records
localLogger.info('reset coming up interview records')
const interview = await Interview.findById('976d23a9-5710-453f-99d9-f57a588bb610')
const startTimestamp = moment().add(moment.duration('PT1H')).add('PT1M').toDate()
const startTimestamp = moment().add(moment.duration(config.INTERVIEW_COMING_UP_REMIND_TIME[0])).add(config.INTERVIEW_COMING_UP_MATCH_WINDOW).toDate()
await interview.update({ startTimestamp, duration: 30, status: Interviews.Status.Scheduled, guestNames: ['test1', 'test2'], hostName: 'hostName' })

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

/**
Expand Down
Loading