Skip to content

Commit 6763c7d

Browse files
Merge pull request #31 from imcaizheng/add-workload-field
add workload field to Job model
2 parents 211532d + 1e50697 commit 6763c7d

File tree

6 files changed

+97
-47
lines changed

6 files changed

+97
-47
lines changed

docs/Topcoder-bookings-api.postman_collection.json

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

docs/swagger.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ paths:
145145
schema:
146146
type: string
147147
description: The skill.
148+
- in: query
149+
name: workload
150+
required: false
151+
schema:
152+
type: string
153+
enum: ['full-time', 'fractional']
154+
description: The rate type.
148155
- in: query
149156
name: rateType
150157
required: false
@@ -1479,6 +1486,10 @@ components:
14791486
type: string
14801487
enum: ['hourly', 'daily', 'weekly', 'monthly']
14811488
description: "The rate type of the job."
1489+
workload:
1490+
type: string
1491+
enum: ['full-time', 'fractional']
1492+
description: "The workload of the job."
14821493
skills:
14831494
type: array
14841495
description: "The skills."
@@ -1557,6 +1568,10 @@ components:
15571568
type: string
15581569
enum: ['hourly', 'daily', 'weekly', 'monthly']
15591570
description: "The rate type of the job."
1571+
workload:
1572+
type: string
1573+
enum: ['full-time', 'fractional']
1574+
description: "The workload of the job."
15601575
skills:
15611576
type: array
15621577
description: "The skills."
@@ -1654,6 +1669,10 @@ components:
16541669
type: string
16551670
enum: ['hourly', 'daily', 'weekly', 'monthly']
16561671
description: "The rate type of the job."
1672+
workload:
1673+
type: string
1674+
enum: ['full-time', 'fractional']
1675+
description: "The workload of the job."
16571676
skills:
16581677
type: array
16591678
description: "The skills."

scripts/createIndex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async function createIndex () {
2323
numPositions: { type: 'integer' },
2424
resourceType: { type: 'keyword' },
2525
rateType: { type: 'keyword' },
26+
workload: { type: 'keyword' },
2627
skills: { type: 'keyword' },
2728
status: { type: 'keyword' },
2829
createdAt: { type: 'date' },

src/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const logger = require('./common/logger')
55

66
Joi.rateType = () => Joi.string().valid('hourly', 'daily', 'weekly', 'monthly')
77
Joi.jobStatus = () => Joi.string().valid('sourcing', 'in-review', 'assigned', 'closed', 'cancelled')
8+
Joi.workload = () => Joi.string().valid('full-time', 'fractional')
89
Joi.jobCandidateStatus = () => Joi.string().valid('open', 'selected', 'shortlist', 'rejected')
910

1011
function buildServices (dir) {

src/models/Job.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ module.exports = (sequelize) => {
9898
type: Sequelize.STRING,
9999
allowNull: false
100100
},
101+
workload: {
102+
field: 'workload',
103+
type: Sequelize.STRING,
104+
allowNull: false
105+
},
101106
skills: {
102107
type: Sequelize.JSONB,
103108
allowNull: false

src/services/JobService.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ createJob.schema = Joi.object().keys({
142142
numPositions: Joi.number().integer().min(1).required(),
143143
resourceType: Joi.string().required(),
144144
rateType: Joi.rateType(),
145+
workload: Joi.workload().default('full-time'),
145146
skills: Joi.array().items(Joi.string().uuid()).required()
146147
}).required()
147148
}).required()
@@ -200,6 +201,7 @@ partiallyUpdateJob.schema = Joi.object().keys({
200201
numPositions: Joi.number().integer().min(1),
201202
resourceType: Joi.string(),
202203
rateType: Joi.rateType(),
204+
workload: Joi.workload(),
203205
skills: Joi.array().items(Joi.string().uuid())
204206
}).required()
205207
}).required()
@@ -227,6 +229,7 @@ fullyUpdateJob.schema = Joi.object().keys({
227229
numPositions: Joi.number().integer().min(1).required(),
228230
resourceType: Joi.string().required(),
229231
rateType: Joi.rateType().required(),
232+
workload: Joi.workload().required(),
230233
skills: Joi.array().items(Joi.string().uuid()).required(),
231234
status: Joi.jobStatus()
232235
}).required()
@@ -286,7 +289,18 @@ async function searchJobs (criteria) {
286289
}
287290
}
288291

289-
_.each(_.pick(criteria, ['projectId', 'externalId', 'description', 'startDate', 'endDate', 'resourceType', 'skill', 'rateType', 'status']), (value, key) => {
292+
_.each(_.pick(criteria, [
293+
'projectId',
294+
'externalId',
295+
'description',
296+
'startDate',
297+
'endDate',
298+
'resourceType',
299+
'skill',
300+
'rateType',
301+
'workload',
302+
'status'
303+
]), (value, key) => {
290304
let must
291305
if (key === 'description') {
292306
must = {
@@ -347,7 +361,16 @@ async function searchJobs (criteria) {
347361
const filter = {
348362
[Op.and]: [{ deletedAt: null }]
349363
}
350-
_.each(_.pick(criteria, ['projectId', 'externalId', 'startDate', 'endDate', 'resourceType', 'rateType', 'status']), (value, key) => {
364+
_.each(_.pick(criteria, [
365+
'projectId',
366+
'externalId',
367+
'startDate',
368+
'endDate',
369+
'resourceType',
370+
'rateType',
371+
'workload',
372+
'status'
373+
]), (value, key) => {
351374
filter[Op.and].push({ [key]: value })
352375
})
353376
if (criteria.description) {
@@ -403,6 +426,7 @@ searchJobs.schema = Joi.object().keys({
403426
resourceType: Joi.string(),
404427
skill: Joi.string().uuid(),
405428
rateType: Joi.rateType(),
429+
workload: Joi.workload(),
406430
status: Joi.jobStatus(),
407431
projectIds: Joi.array().items(Joi.number().integer()).single()
408432
}).required()

0 commit comments

Comments
 (0)