Skip to content

add externalId and resume fields to the JobCanidate model #100

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
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
63 changes: 44 additions & 19 deletions docs/Topcoder-bookings-api.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "cc3d894d-9cf4-4711-bd64-5515b4cf945c",
"_postman_id": "b1144d77-699c-47be-864e-fbe99e7f5c14",
"name": "Topcoder-bookings-api",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -1625,7 +1625,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -1669,7 +1669,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobIdCreatedByM2M}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobIdCreatedByM2M}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -1713,7 +1713,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -1757,7 +1757,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -1801,7 +1801,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -1844,7 +1844,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2043,6 +2043,11 @@
"key": "status",
"value": "shortlist",
"disabled": true
},
{
"key": "externalId",
"value": "300234321",
"disabled": true
}
]
}
Expand Down Expand Up @@ -2103,6 +2108,11 @@
"key": "status",
"value": "shortlist",
"disabled": true
},
{
"key": "externalId",
"value": "300234321",
"disabled": true
}
]
}
Expand Down Expand Up @@ -2163,6 +2173,11 @@
"key": "status",
"value": "shortlist",
"disabled": true
},
{
"key": "externalId",
"value": "300234321",
"disabled": true
}
]
}
Expand Down Expand Up @@ -2221,6 +2236,11 @@
"key": "status",
"value": "shortlist",
"disabled": true
},
{
"key": "externalId",
"value": "300234321",
"disabled": true
}
]
}
Expand Down Expand Up @@ -2279,6 +2299,11 @@
"key": "status",
"value": "shortlist",
"disabled": true
},
{
"key": "externalId",
"value": "300234321",
"disabled": true
}
]
}
Expand All @@ -2298,7 +2323,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\r\n \"status\": \"selected\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"status\": \"selected\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2331,7 +2356,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobIdCreatedByM2M}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\r\n \"status\": \"selected\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobIdCreatedByM2M}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"status\": \"selected\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2364,7 +2389,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\r\n \"status\": \"selected\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"status\": \"selected\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2397,7 +2422,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\r\n \"status\": \"selected\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"status\": \"selected\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2430,7 +2455,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\r\n \"status\": \"selected\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"status\": \"selected\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2463,7 +2488,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"jobId\": \"{{jobId}}\",\r\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\r\n \"status\": \"selected\"\r\n}",
"raw": "{\n \"jobId\": \"{{jobId}}\",\n \"userId\": \"a55fe1bc-1754-45fa-9adc-cf3d6d7c377a\",\n \"status\": \"selected\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2496,7 +2521,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"shortlist\"\r\n}",
"raw": "{\n \"status\": \"shortlist\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2529,7 +2554,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"shortlist\"\r\n}",
"raw": "{\n \"status\": \"shortlist\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2562,7 +2587,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"shortlist\"\r\n}",
"raw": "{\n \"status\": \"shortlist\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2595,7 +2620,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"shortlist\"\r\n}",
"raw": "{\n \"status\": \"shortlist\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2628,7 +2653,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"shortlist\"\r\n}",
"raw": "{\n \"status\": \"shortlist\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -2661,7 +2686,7 @@
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"shortlist\"\r\n}",
"raw": "{\n \"status\": \"shortlist\",\n \"externalId\": \"300234321\",\n \"resume\": \"http://example.com\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down
30 changes: 30 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,12 @@ paths:
type: string
enum: ['open', 'selected', 'shortlist', 'rejected', 'cancelled']
description: The job candidate status.
- in: query
name: externalId
required: false
schema:
type: string
description: The external id.
responses:
'200':
description: OK
Expand Down Expand Up @@ -1797,6 +1803,14 @@ components:
type: string
enum: ['open', 'selected', 'shortlist', 'rejected', 'cancelled']
description: "The job candidate status."
externalId:
type: string
example: "1212"
description: "The external id."
resume:
type: string
example: "http://example.com"
description: "The resume link"
createdAt:
type: string
format: date-time
Expand Down Expand Up @@ -1827,11 +1841,27 @@ components:
format: uuid
example: "a55fe1bc-1754-45fa-9adc-cf3d6d7c377a"
description: "The user id."
externalId:
type: string
example: "1212"
description: "The external id."
resume:
type: string
example: "http://example.com"
description: "The resume link"
JobCandidatePatchRequestBody:
properties:
status:
type: string
enum: ['open', 'selected', 'shortlist', 'rejected', 'cancelled']
externalId:
type: string
example: "1212"
description: "The external id."
resume:
type: string
example: "http://example.com"
description: "The resume link"
JobPatchRequestBody:
properties:
status:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Add externalId and resume fields to the JobCandidate model.
*/

module.exports = {
up: queryInterface => {
return Promise.all([
queryInterface.sequelize.query('ALTER TABLE bookings.job_candidates ADD external_id VARCHAR(255)'),
queryInterface.sequelize.query('ALTER TABLE bookings.job_candidates ADD resume VARCHAR(2048)')
])
},
down: queryInterface => {
return Promise.all([
queryInterface.sequelize.query('ALTER TABLE bookings.job_candidates DROP external_id'),
queryInterface.sequelize.query('ALTER TABLE bookings.job_candidates DROP resume')
])
}
}
2 changes: 2 additions & 0 deletions scripts/createIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async function createIndex () {
jobId: { type: 'keyword' },
userId: { type: 'keyword' },
status: { type: 'keyword' },
externalId: { type: 'keyword' },
resume: { type: 'text' },
createdAt: { type: 'date' },
createdBy: { type: 'keyword' },
updatedAt: { type: 'date' },
Expand Down
7 changes: 7 additions & 0 deletions src/models/JobCandidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ module.exports = (sequelize) => {
type: Sequelize.STRING,
allowNull: false
},
externalId: {
field: 'external_id',
type: Sequelize.STRING
},
resume: {
type: Sequelize.STRING
},
createdAt: {
field: 'created_at',
type: Sequelize.DATE,
Expand Down
19 changes: 13 additions & 6 deletions src/services/JobCandidateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ createJobCandidate.schema = Joi.object().keys({
currentUser: Joi.object().required(),
jobCandidate: Joi.object().keys({
jobId: Joi.string().uuid().required(),
userId: Joi.string().uuid().required()
userId: Joi.string().uuid().required(),
externalId: Joi.string(),
resume: Joi.string().uri()
}).required()
}).required()

Expand Down Expand Up @@ -148,7 +150,9 @@ partiallyUpdateJobCandidate.schema = Joi.object().keys({
currentUser: Joi.object().required(),
id: Joi.string().uuid().required(),
data: Joi.object().keys({
status: Joi.jobCandidateStatus()
status: Joi.jobCandidateStatus(),
externalId: Joi.string(),
resume: Joi.string().uri()
}).required()
}).required()

Expand All @@ -171,7 +175,9 @@ fullyUpdateJobCandidate.schema = Joi.object().keys({
data: Joi.object().keys({
jobId: Joi.string().uuid().required(),
userId: Joi.string().uuid().required(),
status: Joi.jobCandidateStatus()
status: Joi.jobCandidateStatus(),
externalId: Joi.string(),
resume: Joi.string().uri()
}).required()
}).required()

Expand Down Expand Up @@ -236,7 +242,7 @@ async function searchJobCandidates (currentUser, criteria) {
}
}

_.each(_.pick(criteria, ['jobId', 'userId', 'status']), (value, key) => {
_.each(_.pick(criteria, ['jobId', 'userId', 'status', 'externalId']), (value, key) => {
esQuery.body.query.bool.must.push({
term: {
[key]: {
Expand Down Expand Up @@ -266,7 +272,7 @@ async function searchJobCandidates (currentUser, criteria) {
const filter = {
[Op.and]: [{ deletedAt: null }]
}
_.each(_.pick(criteria, ['jobId', 'userId', 'status']), (value, key) => {
_.each(_.pick(criteria, ['jobId', 'userId', 'status', 'externalId']), (value, key) => {
filter[Op.and].push({ [key]: value })
})
const jobCandidates = await JobCandidate.findAll({
Expand Down Expand Up @@ -296,7 +302,8 @@ searchJobCandidates.schema = Joi.object().keys({
sortOrder: Joi.string().valid('desc', 'asc'),
jobId: Joi.string().uuid(),
userId: Joi.string().uuid(),
status: Joi.jobCandidateStatus()
status: Joi.jobCandidateStatus(),
externalId: Joi.string()
}).required()
}).required()

Expand Down