Skip to content

Commit 9d81849

Browse files
authored
Merge pull request #286 from yoution/feature/role-jd
Role & Skills Intake - Job Description Module
2 parents 79e7783 + 42c2ac3 commit 9d81849

File tree

6 files changed

+172
-2
lines changed

6 files changed

+172
-2
lines changed

docs/Topcoder-bookings-api.postman_collection.json

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info": {
3-
"_postman_id": "58b277bb-0d1d-4bbf-919f-c5951ba0e1c0",
3+
"_postman_id": "b25dc4fc-ac96-49a5-b8b0-7700c625d4d0",
44
"name": "Topcoder-bookings-api",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
66
},
@@ -17647,6 +17647,44 @@
1764717647
},
1764817648
"response": []
1764917649
},
17650+
{
17651+
"name": "POST /taas-teams/getSkillsByJobDescription",
17652+
"request": {
17653+
"method": "POST",
17654+
"header": [
17655+
{
17656+
"key": "Authorization",
17657+
"type": "text",
17658+
"value": "Bearer {{token_member}}"
17659+
},
17660+
{
17661+
"key": "Content-Type",
17662+
"type": "text",
17663+
"value": "application/json"
17664+
}
17665+
],
17666+
"body": {
17667+
"mode": "raw",
17668+
"raw": "{\n \"description\": \"nodejs react c++ hello\"\n}",
17669+
"options": {
17670+
"raw": {
17671+
"language": "json"
17672+
}
17673+
}
17674+
},
17675+
"url": {
17676+
"raw": "{{URL}}/taas-teams/getSkillsByJobDescription",
17677+
"host": [
17678+
"{{URL}}"
17679+
],
17680+
"path": [
17681+
"taas-teams",
17682+
"getSkillsByJobDescription"
17683+
]
17684+
}
17685+
},
17686+
"response": []
17687+
},
1765017688
{
1765117689
"name": "POST /taas-teams/email - member-issue-report",
1765217690
"request": {
@@ -27007,4 +27045,4 @@
2700727045
]
2700827046
}
2700927047
]
27010-
}
27048+
}

docs/swagger.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,6 +3170,54 @@ paths:
31703170
application/json:
31713171
schema:
31723172
$ref: "#/components/schemas/Error"
3173+
3174+
/taas-teams/getSkillsByJobDescription:
3175+
post:
3176+
tags:
3177+
- Teams
3178+
description: |
3179+
Get skill list by Job Description
3180+
security:
3181+
- bearerAuth: []
3182+
requestBody:
3183+
content:
3184+
application/json:
3185+
schema:
3186+
$ref: "#/components/schemas/TeamJobDescriptionRequestBody"
3187+
responses:
3188+
"200":
3189+
description: OK
3190+
content:
3191+
application/json:
3192+
schema:
3193+
type : array
3194+
items : {
3195+
$ref: "#/components/schemas/SkillItem"
3196+
}
3197+
"400":
3198+
description: Bad request
3199+
content:
3200+
application/json:
3201+
schema:
3202+
$ref: "#/components/schemas/Error"
3203+
"401":
3204+
description: Not authenticated
3205+
content:
3206+
application/json:
3207+
schema:
3208+
$ref: "#/components/schemas/Error"
3209+
"403":
3210+
description: Forbidden
3211+
content:
3212+
application/json:
3213+
schema:
3214+
$ref: "#/components/schemas/Error"
3215+
"500":
3216+
description: Internal Server Error
3217+
content:
3218+
application/json:
3219+
schema:
3220+
$ref: "#/components/schemas/Error"
31733221
/taas-teams/email:
31743222
post:
31753223
tags:
@@ -3282,6 +3330,15 @@ components:
32823330
scheme: bearer
32833331
bearerFormat: JWT
32843332
schemas:
3333+
SkillItem:
3334+
properties:
3335+
tag:
3336+
type: string
3337+
type:
3338+
type: string
3339+
source:
3340+
type: string
3341+
32853342
Job:
32863343
required:
32873344
- id
@@ -4666,6 +4723,14 @@ components:
46664723
type: array
46674724
items:
46684725
$ref: "#/components/schemas/Skill"
4726+
TeamJobDescriptionRequestBody:
4727+
type: object
4728+
properties:
4729+
description:
4730+
type: string
4731+
description: "job description"
4732+
example: "nodejs and java"
4733+
46694734
TeamEmailRequestBody:
46704735
type: object
46714736
properties:

src/common/helper.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,29 @@ async function substituteStringByObject(string, object) {
16911691
return string;
16921692
}
16931693

1694+
1695+
/**
1696+
* Get tags from tagging service
1697+
* @param {String} description The challenge description
1698+
* @returns {Array} array of tags
1699+
*/
1700+
async function getTags (description) {
1701+
const data = { text: description, extract_confidence: false}
1702+
const type = "emsi/internal_no_refresh"
1703+
const url = `${config.TC_API}/contest-tagging/${type}`;
1704+
const res = await request
1705+
.post(url)
1706+
.set('Accept', 'application/json')
1707+
.send(querystring.stringify(data))
1708+
1709+
localLogger.debug({
1710+
context: 'getTags',
1711+
message: `response body: ${JSON.stringify(res.body)}`,
1712+
});
1713+
return _.get(res, 'body');
1714+
}
1715+
1716+
16941717
/**
16951718
* @param {Object} currentUser the user performing the action
16961719
* @param {Object} data title of project and any other info
@@ -1752,6 +1775,7 @@ module.exports = {
17521775
getMemberDetailsByHandles,
17531776
getMemberDetailsByHandle,
17541777
getMemberDetailsByEmails,
1778+
getTags,
17551779
createProjectMember,
17561780
listProjectMembers,
17571781
listProjectMemberInvites,

src/controllers/TeamController.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ async function getMe(req, res) {
108108
res.send(await service.getMe(req.authUser));
109109
}
110110

111+
112+
/**
113+
* Return skills by job description.
114+
* @param req the request
115+
* @param res the response
116+
*/
117+
async function getSkillsByJobDescription(req, res) {
118+
res.send(await service.getSkillsByJobDescription(req.authUser, req.body));
119+
}
120+
111121
/**
112122
*
113123
* @param req the request
@@ -127,5 +137,6 @@ module.exports = {
127137
searchInvites,
128138
deleteMember,
129139
getMe,
140+
getSkillsByJobDescription,
130141
createProj,
131142
};

src/routes/TeamRoutes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ module.exports = {
3636
scopes: [constants.Scopes.READ_TAAS_TEAM],
3737
},
3838
},
39+
'/taas-teams/getSkillsByJobDescription': {
40+
post: {
41+
controller: 'TeamController',
42+
method: 'getSkillsByJobDescription',
43+
auth: 'jwt',
44+
scopes: [constants.Scopes.READ_TAAS_TEAM],
45+
},
46+
},
3947
'/taas-teams/:id': {
4048
get: {
4149
controller: 'TeamController',

src/services/TeamService.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,29 @@ getMe.schema = Joi.object()
669669
})
670670
.required();
671671

672+
/**
673+
* Return skills by job description.
674+
*
675+
* @param {Object} currentUser the user who perform this operation.
676+
* @params {Object} criteria the search criteria
677+
* @returns {Object} the user data for current user
678+
*/
679+
async function getSkillsByJobDescription(currentUser,data) {
680+
return helper.getTags(data.description)
681+
}
682+
683+
getSkillsByJobDescription.schema = Joi.object()
684+
.keys({
685+
currentUser: Joi.object().required(),
686+
data: Joi.object()
687+
.keys({
688+
description: Joi.string().required(),
689+
})
690+
.required(),
691+
})
692+
.required();
693+
694+
672695
/**
673696
* @param {Object} currentUser the user performing the operation.
674697
* @param {Object} data project data
@@ -695,5 +718,6 @@ module.exports = {
695718
searchInvites,
696719
deleteMember,
697720
getMe,
721+
getSkillsByJobDescription,
698722
createProj,
699723
};

0 commit comments

Comments
 (0)