Skip to content

Commit a5d52cb

Browse files
authored
Merge pull request #215 from cagdas001/feature/interview-scheduler2
feat: add interview scheduler
2 parents 04fe63d + 75ddf18 commit a5d52cb

29 files changed

+9924
-2817
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
AUTH0_AUDIENCE_UBAHN=
3535
AUTH0_CLIENT_ID=
3636
AUTH0_CLIENT_SECRET=
37-
37+
# necessary if you'll utilize email functionality of interviews
38+
INTERVIEW_INVITATION_SENDGRID_TEMPLATE_ID=
39+
INTERVIEW_INVITATION_SENDER_EMAIL=
3840
# Locally deployed services (via docker-compose)
3941
ES_HOST=dockerhost:9200
4042
DATABASE_URL=postgres://postgres:postgres@dockerhost:5432/postgres

app-constants.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,28 @@ const Scopes = {
4444
READ_WORK_PERIOD_PAYMENT: 'read:taas-workPeriodPayments',
4545
CREATE_WORK_PERIOD_PAYMENT: 'create:taas-workPeriodPayments',
4646
UPDATE_WORK_PERIOD_PAYMENT: 'update:taas-workPeriodPayments',
47-
ALL_WORK_PERIOD_PAYMENT: 'all:taas-workPeriodPayments'
47+
ALL_WORK_PERIOD_PAYMENT: 'all:taas-workPeriodPayments',
48+
// interview
49+
READ_INTERVIEW: 'read:taas-interviews',
50+
CREATE_INTERVIEW: 'create:taas-interviews',
51+
UPDATE_INTERVIEW: 'update:taas-interviews',
52+
ALL_INTERVIEW: 'all:taas-interviews'
53+
}
54+
55+
// Interview related constants
56+
const Interviews = {
57+
Status: {
58+
Scheduling: 'Scheduling',
59+
Scheduled: 'Scheduled',
60+
RequestedForReschedule: 'Requested for reschedule',
61+
Rescheduled: 'Rescheduled',
62+
Completed: 'Completed',
63+
Cancelled: 'Cancelled'
64+
},
65+
XaiTemplate: {
66+
'30MinInterview': '30-min-interview',
67+
'60MinInterview': '60-min-interview'
68+
}
4869
}
4970

5071
const ChallengeStatus = {
@@ -62,6 +83,7 @@ module.exports = {
6283
UserRoles,
6384
FullManagePermissionRoles,
6485
Scopes,
86+
Interviews,
6587
ChallengeStatus,
6688
PaymentProcessingSwitch
6789
}

app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const express = require('express')
99
const cors = require('cors')
1010
const HttpStatus = require('http-status-codes')
1111
const interceptor = require('express-interceptor')
12+
const schedule = require('node-schedule')
1213
const logger = require('./src/common/logger')
1314
const eventHandlers = require('./src/eventHandlers')
15+
const interviewService = require('./src/services/InterviewService')
1416

1517
// setup express app
1618
const app = express()
@@ -93,6 +95,8 @@ app.use((err, req, res, next) => {
9395
const server = app.listen(app.get('port'), () => {
9496
logger.info({ component: 'app', message: `Express server listening on port ${app.get('port')}` })
9597
eventHandlers.init()
98+
// schedule updateCompletedInterviews to run every hour
99+
schedule.scheduleJob('0 0 * * * *', interviewService.updateCompletedInterviews)
96100
})
97101

98102
if (process.env.NODE_ENV === 'test') {

config/default.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ module.exports = {
126126
TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC: process.env.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC || 'taas.workperiodpayment.update',
127127
// the delete work period payment entity Kafka message topic
128128
TAAS_WORK_PERIOD_PAYMENT_DELETE_TOPIC: process.env.TAAS_WORK_PERIOD_PAYMENT_DELETE_TOPIC || 'taas.workperiodpayment.delete',
129+
// topics for interview service
130+
// the request interview Kafka message topic
131+
TAAS_INTERVIEW_REQUEST_TOPIC: process.env.TAAS_INTERVIEW_REQUEST_TOPIC || 'taas.interview.requested',
132+
// the interview update Kafka message topic
133+
TAAS_INTERVIEW_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_UPDATE_TOPIC || 'taas.interview.update',
134+
// the interview bulk update Kafka message topic
135+
TAAS_INTERVIEW_BULK_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_BULK_UPDATE_TOPIC || 'taas.interview.bulkUpdate',
129136

130137
// the Kafka message topic for sending email
131138
EMAIL_TOPIC: process.env.EMAIL_TOPIC || 'external.action.email',
@@ -135,10 +142,18 @@ module.exports = {
135142
// the emails address for receiving the issue report
136143
// REPORT_ISSUE_EMAILS may contain comma-separated list of email which is converted to array
137144
REQUEST_EXTENSION_EMAILS: (process.env.REQUEST_EXTENSION_EMAILS || '').split(','),
145+
// the emails address for interview invitation
146+
// INTERVIEW_INVITATION_CC_LIST may contain comma-separated list of email which is converted to array
147+
// scheduler@x.ai should be in the CC list
148+
INTERVIEW_INVITATION_CC_LIST: (process.env.INTERVIEW_INVITATION_CC_LIST || 'scheduler@x.ai').split(','),
138149
// SendGrid email template ID for reporting issue
139150
REPORT_ISSUE_SENDGRID_TEMPLATE_ID: process.env.REPORT_ISSUE_SENDGRID_TEMPLATE_ID,
140151
// SendGrid email template ID for requesting extension
141152
REQUEST_EXTENSION_SENDGRID_TEMPLATE_ID: process.env.REQUEST_EXTENSION_SENDGRID_TEMPLATE_ID,
153+
// SendGrid email template ID for interview invitation
154+
INTERVIEW_INVITATION_SENDGRID_TEMPLATE_ID: process.env.INTERVIEW_INVITATION_SENDGRID_TEMPLATE_ID,
155+
// The sender (aka `from`) email for invitation.
156+
INTERVIEW_INVITATION_SENDER_EMAIL: process.env.INTERVIEW_INVITATION_SENDER_EMAIL,
142157
// the URL where TaaS App is hosted
143158
TAAS_APP_URL: process.env.TAAS_APP_URL || 'https://platform.topcoder-dev.com/taas/myteams',
144159
// environment variables for Payment Service

config/email_template.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,29 @@ module.exports = {
5959
'{{text}}',
6060
recipients: config.REPORT_ISSUE_EMAILS,
6161
sendgridTemplateId: config.REQUEST_EXTENSION_SENDGRID_TEMPLATE_ID
62+
},
63+
64+
/* Request interview for a job candidate
65+
*
66+
* - interviewType: the x.ai interview type. Example: "30-min-interview"
67+
* - candidateName: Full name of candidate. Example: "John Doe"
68+
* - jobName: The title of the job. Example: "TaaS API Misc Updates"
69+
* - customMessage: if it's needed, a custom message can be added to the end of email. Example: "I would like to invite you for an interview..."
70+
*
71+
* Template (defined in SendGrid):
72+
* Subject: '/{{interviewType}} tech interview with {{candidateName}} for {{jobName}} is requested by the Customer'
73+
* Body:
74+
* 'The customer has requested /{{interviewType}} with {{candidateName}} for {{jobName}}.'
75+
* + 'In a few minutes you will receive an invitation from our scheduling tool. Please proceed with the invitation to agree on timing.'
76+
* + '<br /><br />{{customMessage}}'
77+
*
78+
* Note, that the template should be defined in SendGrid.
79+
* The subject & body above (identical to actual SendGrid template) is for reference purposes.
80+
* We won't pass subject & body but only substitutions (replacements in template subject/body).
81+
*/
82+
'interview-invitation': {
83+
from: config.INTERVIEW_INVITATION_SENDER_EMAIL,
84+
cc: config.INTERVIEW_INVITATION_CC_LIST,
85+
sendgridTemplateId: config.INTERVIEW_INVITATION_SENDGRID_TEMPLATE_ID
6286
}
6387
}

0 commit comments

Comments
 (0)