Skip to content

Commit 2b029d3

Browse files
authored
Merge pull request #377 from topcoder-platform/roles-finalfix
Roles finalfix challenge
2 parents d9ae1d3 + 8670e7f commit 2b029d3

File tree

5 files changed

+49
-16
lines changed

5 files changed

+49
-16
lines changed

data/demo-data.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7646,10 +7646,10 @@
76467646
"name": "Angular Developer",
76477647
"description": "* Writes tested and documented JavaScript, HTML and CSS\n* Makes design and technical decisions for AngularJS projects\n* Develops application code and unit test in the AngularJS, Rest Web Services and Java technologies",
76487648
"listOfSkills": [
7649-
"database",
7650-
"winforms",
7651-
"user interface (ui)",
7652-
"photoshop"
7649+
"Database",
7650+
"Winforms",
7651+
"User Interface (Ui)",
7652+
"Photoshop"
76537653
],
76547654
"rates": [
76557655
{
@@ -7678,10 +7678,10 @@
76787678
"name": "Dev Ops Engineer",
76797679
"description": "* Introduces processes, tools, and methodologies\n* Balances needs throughout the software development life cycle\n* Configures server images, optimizes task performance in correspondence with engineers",
76807680
"listOfSkills": [
7681-
"dropwizard",
7682-
"nginx",
7683-
"machine learning",
7684-
"force.com"
7681+
"Dropwizard",
7682+
"NGINX",
7683+
"Machine Learning",
7684+
"Force.com"
76857685
],
76867686
"rates": [
76877687
{
@@ -7722,10 +7722,10 @@
77227722
"name": "Salesforce Developer",
77237723
"description": "* Meets with project managers to determine CRM needs\n* Develops customized solutions within the Salesforce platform\n* Designs, codes, and implements Salesforce applications\n* Creates timelines and development goals\n* Tests the stability and functionality of the application\n* Troubleshoots and fixes bugs\n* Writes documents and provides technical training for Salesforce Staff\n* Maintains the security and integrity of the application software",
77247724
"listOfSkills": [
7725-
"docker",
7726-
".net",
7725+
"Docker",
7726+
".NET",
77277727
"appcelerator",
7728-
"flux"
7728+
"Flux"
77297729
],
77307730
"rates": [
77317731
{

docs/swagger.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5249,6 +5249,9 @@ components:
52495249
jobDescription:
52505250
type: string
52515251
description: "The description of the job."
5252+
jobTitle:
5253+
type: string
5254+
description: "An optional job title."
52525255
- type: object
52535256
required:
52545257
- skills
@@ -5281,6 +5284,10 @@ components:
52815284
format: float
52825285
description: "Rate at which searched skills match the given role"
52835286
example: 0.75
5287+
jobTitle:
5288+
type: string
5289+
description: "Optional job title."
5290+
example: "Lead Application Developer"
52845291
SubmitTeamRequestBody:
52855292
properties:
52865293
teamName:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const config = require('config')
2+
3+
/**
4+
* Add jobTitle field to the RoleSearchRequest model.
5+
*/
6+
7+
module.exports = {
8+
up: async (queryInterface, Sequelize) => {
9+
await queryInterface.addColumn({ tableName: 'role_search_requests', schema: config.DB_SCHEMA_NAME }, 'job_title',
10+
{
11+
type: Sequelize.STRING(100),
12+
allowNull: true
13+
})
14+
},
15+
down: async (queryInterface, Sequelize) => {
16+
await queryInterface.removeColumn({ tableName: 'role_search_requests', schema: config.DB_SCHEMA_NAME}, 'job_title')
17+
}
18+
}

src/models/RoleSearchRequest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ module.exports = (sequelize) => {
6262
type: Sequelize.UUID
6363
})
6464
},
65+
jobTitle: {
66+
field: 'job_title',
67+
type: Sequelize.STRING(100),
68+
allowNull: true
69+
},
6570
createdBy: {
6671
field: 'created_by',
6772
type: Sequelize.UUID,

src/services/TeamService.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const errors = require('../common/errors')
1313
const JobService = require('./JobService')
1414
const ResourceBookingService = require('./ResourceBookingService')
1515
const HttpStatus = require('http-status-codes')
16-
const { Op } = require('sequelize')
16+
const { Op, where, fn, col } = require('sequelize')
1717
const models = require('../models')
1818
const stopWords = require('../../data/stopWords.json')
1919
const { getAuditM2Muser } = require('../common/helper')
@@ -776,11 +776,12 @@ async function roleSearchRequest (currentUser, data) {
776776
}
777777
data.roleId = role.id
778778
// create roleSearchRequest entity with found roleId
779-
const { id: roleSearchRequestId } = await createRoleSearchRequest(currentUser, data)
779+
const { id: roleSearchRequestId, jobTitle } = await createRoleSearchRequest(currentUser, data)
780+
const entity = jobTitle ? { jobTitle, roleSearchRequestId } : { roleSearchRequestId };
780781
// clean Role
781782
role = await _cleanRoleDTO(currentUser, role)
782783
// return Role
783-
return _.assign(role, { roleSearchRequestId })
784+
return _.assign(role, entity)
784785
}
785786

786787
roleSearchRequest.schema = Joi.object()
@@ -789,8 +790,10 @@ roleSearchRequest.schema = Joi.object()
789790
data: Joi.object().keys({
790791
roleId: Joi.string().uuid(),
791792
jobDescription: Joi.string().max(255),
792-
skills: Joi.array().items(Joi.string().uuid().required())
793-
}).required().min(1)
793+
skills: Joi.array().items(Joi.string().uuid().required()),
794+
jobTitle: Joi.string().max(100),
795+
previousRoleSearchRequestId: Joi.string().uuid()
796+
}).required().or('roleId', 'jobDescription', 'skills')
794797
}).required()
795798

796799
/**

0 commit comments

Comments
 (0)