Skip to content

Commit bc9915e

Browse files
Merge pull request #145 from imcaizheng/job-replace-end-date-with-duration
Remove `endDate` from Job and add `duration` to Job
2 parents 9562310 + 331a855 commit bc9915e

File tree

9 files changed

+82
-118
lines changed

9 files changed

+82
-118
lines changed

docs/Topcoder-bookings-api.postman_collection.json

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

docs/swagger.yaml

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ paths:
9191
schema:
9292
type: string
9393
default: id
94-
enum: ['id','createdAt','startDate','endDate','rateType','status']
94+
enum: ['id','createdAt','startDate','rateType','status']
9595
description: The sort by column.
9696
- in: query
9797
name: sortOrder
@@ -139,13 +139,6 @@ paths:
139139
type: string
140140
format: date-time
141141
description: The job start date.
142-
- in: query
143-
name: endDate
144-
required: false
145-
schema:
146-
type: string
147-
format: date-time
148-
description: The job end date.
149142
- in: query
150143
name: resourceType
151144
required: false
@@ -1683,11 +1676,10 @@ components:
16831676
format: date-time
16841677
example: "2020-09-27T04:17:23.131Z"
16851678
description: "The job start date."
1686-
endDate:
1687-
type: string
1688-
format: date-time
1689-
example: "2020-09-27T04:17:23.131Z"
1690-
description: "The job end date."
1679+
duration:
1680+
type: integer
1681+
example: 1
1682+
description: "The duration in weeks"
16911683
numPositions:
16921684
type: integer
16931685
example: 13
@@ -1770,11 +1762,10 @@ components:
17701762
format: date-time
17711763
example: "2020-09-27T04:17:23.131Z"
17721764
description: "The job start date."
1773-
endDate:
1774-
type: string
1775-
format: date-time
1776-
example: "2020-09-27T04:17:23.131Z"
1777-
description: "The job end date."
1765+
duration:
1766+
type: integer
1767+
example: 1
1768+
description: "The duration in weeks"
17781769
numPositions:
17791770
type: integer
17801771
example: 13
@@ -1900,11 +1891,10 @@ components:
19001891
format: date-time
19011892
example: "2020-09-27T04:17:23.131Z"
19021893
description: "The job start date."
1903-
endDate:
1904-
type: string
1905-
format: date-time
1906-
example: "2020-09-27T04:17:23.131Z"
1907-
description: "The job end date."
1894+
duration:
1895+
type: integer
1896+
example: 1
1897+
description: "The duration in weeks"
19081898
numPositions:
19091899
type: integer
19101900
example: 13
@@ -2315,11 +2305,10 @@ components:
23152305
format: date-time
23162306
example: "2020-09-27T04:17:23.131Z"
23172307
description: "The job start date."
2318-
endDate:
2319-
type: string
2320-
format: date-time
2321-
example: "2020-09-27T04:17:23.131Z"
2322-
description: "The job end date."
2308+
duration:
2309+
type: integer
2310+
example: 1
2311+
description: "The duration in weeks"
23232312
numPositions:
23242313
type: integer
23252314
example: 13
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Replace endData with duration in Job model.
3+
*/
4+
5+
module.exports = {
6+
up: queryInterface => {
7+
return Promise.all([
8+
queryInterface.sequelize.query('ALTER TABLE bookings.jobs DROP end_date'),
9+
queryInterface.sequelize.query('ALTER TABLE bookings.jobs ADD duration INTEGER')
10+
])
11+
},
12+
down: queryInterface => {
13+
return Promise.all([
14+
queryInterface.sequelize.query('ALTER TABLE bookings.jobs ADD end_date DATE'),
15+
queryInterface.sequelize.query('ALTER TABLE bookings.jobs DROP duration')
16+
])
17+
}
18+
}

src/common/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ esIndexPropertyMapping[config.get('esConfig.ES_INDEX_JOB')] = {
6060
description: { type: 'text' },
6161
title: { type: 'text' },
6262
startDate: { type: 'date' },
63-
endDate: { type: 'date' },
63+
duration: { type: 'integer' },
6464
numPositions: { type: 'integer' },
6565
resourceType: { type: 'keyword' },
6666
rateType: { type: 'keyword' },

src/models/Job.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ module.exports = (sequelize) => {
6969
field: 'start_date',
7070
type: Sequelize.DATE
7171
},
72-
endDate: {
73-
field: 'end_date',
74-
type: Sequelize.DATE
72+
duration: {
73+
field: 'duration',
74+
type: Sequelize.INTEGER
7575
},
7676
numPositions: {
7777
field: 'num_positions',
@@ -109,7 +109,7 @@ module.exports = (sequelize) => {
109109
},
110110
createdAt: {
111111
field: 'created_at',
112-
type: Sequelize.DATE,
112+
type: Sequelize.DATE
113113
},
114114
updatedAt: {
115115
field: 'updated_at',

src/models/JobCandidate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = (sequelize) => {
7070
},
7171
createdAt: {
7272
field: 'created_at',
73-
type: Sequelize.DATE,
73+
type: Sequelize.DATE
7474
},
7575
updatedAt: {
7676
field: 'updated_at',

src/models/ResourceBooking.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module.exports = (sequelize) => {
8787
},
8888
createdAt: {
8989
field: 'created_at',
90-
type: Sequelize.DATE,
90+
type: Sequelize.DATE
9191
},
9292
updatedAt: {
9393
field: 'updated_at',

src/services/JobService.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ createJob.schema = Joi.object().keys({
166166
description: Joi.stringAllowEmpty().allow(null),
167167
title: Joi.title().required(),
168168
startDate: Joi.date().allow(null),
169-
endDate: Joi.date().allow(null),
169+
duration: Joi.number().integer().min(1).allow(null),
170170
numPositions: Joi.number().integer().min(1).required(),
171171
resourceType: Joi.stringAllowEmpty().allow(null),
172172
rateType: Joi.rateType().allow(null),
@@ -227,7 +227,7 @@ partiallyUpdateJob.schema = Joi.object().keys({
227227
description: Joi.stringAllowEmpty().allow(null),
228228
title: Joi.title(),
229229
startDate: Joi.date().allow(null),
230-
endDate: Joi.date().allow(null),
230+
duration: Joi.number().integer().min(1).allow(null),
231231
numPositions: Joi.number().integer().min(1),
232232
resourceType: Joi.stringAllowEmpty().allow(null),
233233
rateType: Joi.rateType().allow(null),
@@ -256,7 +256,7 @@ fullyUpdateJob.schema = Joi.object().keys({
256256
description: Joi.stringAllowEmpty().allow(null),
257257
title: Joi.title().required(),
258258
startDate: Joi.date().allow(null),
259-
endDate: Joi.date().allow(null),
259+
duration: Joi.number().integer().min(1).allow(null),
260260
numPositions: Joi.number().integer().min(1).required(),
261261
resourceType: Joi.stringAllowEmpty().allow(null),
262262
rateType: Joi.rateType().allow(null),
@@ -344,7 +344,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
344344
'externalId',
345345
'description',
346346
'startDate',
347-
'endDate',
348347
'resourceType',
349348
'skill',
350349
'rateType',
@@ -414,7 +413,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
414413
'projectId',
415414
'externalId',
416415
'startDate',
417-
'endDate',
418416
'resourceType',
419417
'rateType',
420418
'workload',
@@ -462,14 +460,13 @@ searchJobs.schema = Joi.object().keys({
462460
criteria: Joi.object().keys({
463461
page: Joi.number().integer(),
464462
perPage: Joi.number().integer(),
465-
sortBy: Joi.string().valid('id', 'createdAt', 'startDate', 'endDate', 'rateType', 'status'),
463+
sortBy: Joi.string().valid('id', 'createdAt', 'startDate', 'rateType', 'status'),
466464
sortOrder: Joi.string().valid('desc', 'asc'),
467465
projectId: Joi.number().integer(),
468466
externalId: Joi.string(),
469467
description: Joi.string(),
470468
title: Joi.title(),
471469
startDate: Joi.date(),
472-
endDate: Joi.date(),
473470
resourceType: Joi.string(),
474471
skill: Joi.string().uuid(),
475472
rateType: Joi.rateType(),

src/services/TeamService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
188188
}
189189
} else {
190190
res.jobs = _.map(jobsTmp, job => {
191-
return _.pick(job, ['id', 'description', 'startDate', 'endDate', 'numPositions', 'rateType', 'skills', 'customerRate', 'status', 'title'])
191+
return _.pick(job, ['id', 'description', 'startDate', 'duration', 'numPositions', 'rateType', 'skills', 'customerRate', 'status', 'title'])
192192
})
193193
}
194194
}

0 commit comments

Comments
 (0)