Skip to content

Remove endDate from Job and add duration to Job #145

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
110 changes: 35 additions & 75 deletions docs/Topcoder-bookings-api.postman_collection.json

Large diffs are not rendered by default.

45 changes: 17 additions & 28 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ paths:
schema:
type: string
default: id
enum: ['id','createdAt','startDate','endDate','rateType','status']
enum: ['id','createdAt','startDate','rateType','status']
description: The sort by column.
- in: query
name: sortOrder
Expand Down Expand Up @@ -139,13 +139,6 @@ paths:
type: string
format: date-time
description: The job start date.
- in: query
name: endDate
required: false
schema:
type: string
format: date-time
description: The job end date.
- in: query
name: resourceType
required: false
Expand Down Expand Up @@ -1683,11 +1676,10 @@ components:
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job start date."
endDate:
type: string
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job end date."
duration:
type: integer
example: 1
description: "The duration in weeks"
numPositions:
type: integer
example: 13
Expand Down Expand Up @@ -1770,11 +1762,10 @@ components:
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job start date."
endDate:
type: string
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job end date."
duration:
type: integer
example: 1
description: "The duration in weeks"
numPositions:
type: integer
example: 13
Expand Down Expand Up @@ -1900,11 +1891,10 @@ components:
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job start date."
endDate:
type: string
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job end date."
duration:
type: integer
example: 1
description: "The duration in weeks"
numPositions:
type: integer
example: 13
Expand Down Expand Up @@ -2315,11 +2305,10 @@ components:
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job start date."
endDate:
type: string
format: date-time
example: "2020-09-27T04:17:23.131Z"
description: "The job end date."
duration:
type: integer
example: 1
description: "The duration in weeks"
numPositions:
type: integer
example: 13
Expand Down
18 changes: 18 additions & 0 deletions migrations/2021-02-10-job-replace-end-date-with-duration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Replace endData with duration in Job model.
*/

module.exports = {
up: queryInterface => {
return Promise.all([
queryInterface.sequelize.query('ALTER TABLE bookings.jobs DROP end_date'),
queryInterface.sequelize.query('ALTER TABLE bookings.jobs ADD duration INTEGER')
])
},
down: queryInterface => {
return Promise.all([
queryInterface.sequelize.query('ALTER TABLE bookings.jobs ADD end_date DATE'),
queryInterface.sequelize.query('ALTER TABLE bookings.jobs DROP duration')
])
}
}
2 changes: 1 addition & 1 deletion src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ esIndexPropertyMapping[config.get('esConfig.ES_INDEX_JOB')] = {
description: { type: 'text' },
title: { type: 'text' },
startDate: { type: 'date' },
endDate: { type: 'date' },
duration: { type: 'integer' },
numPositions: { type: 'integer' },
resourceType: { type: 'keyword' },
rateType: { type: 'keyword' },
Expand Down
8 changes: 4 additions & 4 deletions src/models/Job.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ module.exports = (sequelize) => {
field: 'start_date',
type: Sequelize.DATE
},
endDate: {
field: 'end_date',
type: Sequelize.DATE
duration: {
field: 'duration',
type: Sequelize.INTEGER
},
numPositions: {
field: 'num_positions',
Expand Down Expand Up @@ -109,7 +109,7 @@ module.exports = (sequelize) => {
},
createdAt: {
field: 'created_at',
type: Sequelize.DATE,
type: Sequelize.DATE
},
updatedAt: {
field: 'updated_at',
Expand Down
2 changes: 1 addition & 1 deletion src/models/JobCandidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = (sequelize) => {
},
createdAt: {
field: 'created_at',
type: Sequelize.DATE,
type: Sequelize.DATE
},
updatedAt: {
field: 'updated_at',
Expand Down
2 changes: 1 addition & 1 deletion src/models/ResourceBooking.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = (sequelize) => {
},
createdAt: {
field: 'created_at',
type: Sequelize.DATE,
type: Sequelize.DATE
},
updatedAt: {
field: 'updated_at',
Expand Down
11 changes: 4 additions & 7 deletions src/services/JobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ createJob.schema = Joi.object().keys({
description: Joi.stringAllowEmpty().allow(null),
title: Joi.title().required(),
startDate: Joi.date().allow(null),
endDate: Joi.date().allow(null),
duration: Joi.number().integer().min(1).allow(null),
numPositions: Joi.number().integer().min(1).required(),
resourceType: Joi.stringAllowEmpty().allow(null),
rateType: Joi.rateType().allow(null),
Expand Down Expand Up @@ -227,7 +227,7 @@ partiallyUpdateJob.schema = Joi.object().keys({
description: Joi.stringAllowEmpty().allow(null),
title: Joi.title(),
startDate: Joi.date().allow(null),
endDate: Joi.date().allow(null),
duration: Joi.number().integer().min(1).allow(null),
numPositions: Joi.number().integer().min(1),
resourceType: Joi.stringAllowEmpty().allow(null),
rateType: Joi.rateType().allow(null),
Expand Down Expand Up @@ -256,7 +256,7 @@ fullyUpdateJob.schema = Joi.object().keys({
description: Joi.stringAllowEmpty().allow(null),
title: Joi.title().required(),
startDate: Joi.date().allow(null),
endDate: Joi.date().allow(null),
duration: Joi.number().integer().min(1).allow(null),
numPositions: Joi.number().integer().min(1).required(),
resourceType: Joi.stringAllowEmpty().allow(null),
rateType: Joi.rateType().allow(null),
Expand Down Expand Up @@ -344,7 +344,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
'externalId',
'description',
'startDate',
'endDate',
'resourceType',
'skill',
'rateType',
Expand Down Expand Up @@ -414,7 +413,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
'projectId',
'externalId',
'startDate',
'endDate',
'resourceType',
'rateType',
'workload',
Expand Down Expand Up @@ -462,14 +460,13 @@ searchJobs.schema = Joi.object().keys({
criteria: Joi.object().keys({
page: Joi.number().integer(),
perPage: Joi.number().integer(),
sortBy: Joi.string().valid('id', 'createdAt', 'startDate', 'endDate', 'rateType', 'status'),
sortBy: Joi.string().valid('id', 'createdAt', 'startDate', 'rateType', 'status'),
sortOrder: Joi.string().valid('desc', 'asc'),
projectId: Joi.number().integer(),
externalId: Joi.string(),
description: Joi.string(),
title: Joi.title(),
startDate: Joi.date(),
endDate: Joi.date(),
resourceType: Joi.string(),
skill: Joi.string().uuid(),
rateType: Joi.rateType(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/TeamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async function getTeamDetail (currentUser, projects, isSearch = true) {
}
} else {
res.jobs = _.map(jobsTmp, job => {
return _.pick(job, ['id', 'description', 'startDate', 'endDate', 'numPositions', 'rateType', 'skills', 'customerRate', 'status', 'title'])
return _.pick(job, ['id', 'description', 'startDate', 'duration', 'numPositions', 'rateType', 'skills', 'customerRate', 'status', 'title'])
})
}
}
Expand Down