Skip to content

Commit 0304e68

Browse files
committed
feat(job-service): accept roles array
* Add `roles` in Job schema. * Accept `roles` in the Job related endpoints. * Fix demo-data (was blocking `npm run local:init` script).
1 parent 79e7783 commit 0304e68

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

data/demo-data.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
"jobCandidateId": "881a19de-2b0c-4bb9-b36a-4cb5e223bdb5",
185185
"googleCalendarId": null,
186186
"customMessage": null,
187-
"xaiTemplate": "interview-30",
187+
"templateUrl": "interview-30",
188188
"round": 1,
189189
"startTimestamp": null,
190190
"attendeesList": null,
@@ -213,7 +213,7 @@
213213
"jobCandidateId": "827ee401-df04-42e1-abbe-7b97ce7937ff",
214214
"googleCalendarId": "dummyId",
215215
"customMessage": "This is a custom message",
216-
"xaiTemplate": "interview-30",
216+
"templateUrl": "interview-30",
217217
"round": 2,
218218
"startTimestamp": null,
219219
"attendeesList": null,
@@ -228,7 +228,7 @@
228228
"jobCandidateId": "827ee401-df04-42e1-abbe-7b97ce7937ff",
229229
"googleCalendarId": null,
230230
"customMessage": null,
231-
"xaiTemplate": "interview-30",
231+
"templateUrl": "interview-30",
232232
"round": 1,
233233
"startTimestamp": null,
234234
"attendeesList": null,
@@ -257,7 +257,7 @@
257257
"jobCandidateId": "a4ea7bcf-5b99-4381-b99c-a9bd05d83a36",
258258
"googleCalendarId": "dummyId",
259259
"customMessage": "This is a custom message",
260-
"xaiTemplate": "interview-30",
260+
"templateUrl": "interview-30",
261261
"round": 3,
262262
"startTimestamp": null,
263263
"attendeesList": [
@@ -275,7 +275,7 @@
275275
"jobCandidateId": "a4ea7bcf-5b99-4381-b99c-a9bd05d83a36",
276276
"googleCalendarId": "dummyId",
277277
"customMessage": "This is a custom message",
278-
"xaiTemplate": "interview-30",
278+
"templateUrl": "interview-30",
279279
"round": 2,
280280
"startTimestamp": null,
281281
"attendeesList": [
@@ -293,7 +293,7 @@
293293
"jobCandidateId": "a4ea7bcf-5b99-4381-b99c-a9bd05d83a36",
294294
"googleCalendarId": null,
295295
"customMessage": null,
296-
"xaiTemplate": "interview-30",
296+
"templateUrl": "interview-30",
297297
"round": 1,
298298
"startTimestamp": null,
299299
"attendeesList": null,

src/common/helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ esIndexPropertyMapping[config.get('esConfig.ES_INDEX_JOB')] = {
111111
rateType: { type: 'keyword' },
112112
workload: { type: 'keyword' },
113113
skills: { type: 'keyword' },
114+
roles: { type: 'keyword' },
114115
status: { type: 'keyword' },
115116
isApplicationPageActive: { type: 'boolean' },
116117
createdAt: { type: 'date' },

src/models/Job.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ module.exports = (sequelize) => {
9494
type: Sequelize.JSONB,
9595
allowNull: false
9696
},
97+
roles: {
98+
type: Sequelize.ARRAY(Sequelize.UUID)
99+
},
97100
status: {
98101
type: Sequelize.STRING(255),
99102
allowNull: false

src/services/JobService.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ createJob.schema = Joi.object().keys({
177177
rateType: Joi.rateType().allow(null),
178178
workload: Joi.workload().allow(null),
179179
skills: Joi.array().items(Joi.string().uuid()).required(),
180+
roles: Joi.array().items(Joi.string().uuid()).allow(null),
180181
isApplicationPageActive: Joi.boolean()
181182
}).required()
182183
}).required()
@@ -245,6 +246,7 @@ partiallyUpdateJob.schema = Joi.object().keys({
245246
rateType: Joi.rateType().allow(null),
246247
workload: Joi.workload().allow(null),
247248
skills: Joi.array().items(Joi.string().uuid()),
249+
roles: Joi.array().items(Joi.string().uuid()).allow(null),
248250
isApplicationPageActive: Joi.boolean()
249251
}).required()
250252
}).required()
@@ -361,6 +363,7 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
361363
'startDate',
362364
'resourceType',
363365
'skill',
366+
'role',
364367
'rateType',
365368
'workload',
366369
'title',
@@ -375,10 +378,10 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
375378
}
376379
}
377380
}
378-
} else if (key === 'skill') {
381+
} else if (key === 'skill' || key === 'role') {
379382
must = {
380383
terms: {
381-
skills: [value]
384+
[`${key}s`]: [value]
382385
}
383386
}
384387
} else {
@@ -453,9 +456,14 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
453456
[Op.like]: `%${criteria.title}%`
454457
}
455458
}
456-
if (criteria.skills) {
459+
if (criteria.skill) {
457460
filter.skills = {
458-
[Op.contains]: [criteria.skills]
461+
[Op.contains]: [criteria.skill]
462+
}
463+
}
464+
if (criteria.role) {
465+
filter.roles = {
466+
[Op.contains]: [criteria.role]
459467
}
460468
}
461469
if (criteria.jobIds && criteria.jobIds.length > 0) {
@@ -495,6 +503,7 @@ searchJobs.schema = Joi.object().keys({
495503
startDate: Joi.date(),
496504
resourceType: Joi.string(),
497505
skill: Joi.string().uuid(),
506+
role: Joi.string().uuid(),
498507
rateType: Joi.rateType(),
499508
workload: Joi.workload(),
500509
status: Joi.jobStatus(),

0 commit comments

Comments
 (0)