Skip to content

Commit 38c8d33

Browse files
authored
Merge pull request #287 from topcoder-platform/feature/role-jd
Feature/role jd
2 parents 59c6e41 + 0876aea commit 38c8d33

File tree

6 files changed

+195
-21
lines changed

6 files changed

+195
-21
lines changed

docs/Topcoder-bookings-api.postman_collection.json

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22554,23 +22554,65 @@
2255422554
]
2255522555
},
2255622556
{
22557-
"name": "Delete Role",
22558-
"item": [
22559-
{
22560-
"name": "delete role with connect user",
22561-
"event": [
22562-
{
22563-
"listen": "test",
22564-
"script": {
22565-
"exec": [
22566-
"pm.test('Status code is 403', function () {\r",
22567-
" pm.response.to.have.status(403);\r",
22568-
" const response = pm.response.json()\r",
22569-
" pm.expect(response.message).to.eq(\"You are not allowed to perform this action!\")\r",
22570-
"});"
22571-
],
22572-
"type": "text/javascript"
22573-
}
22557+
"name": "POST /taas-teams/getSkillsByJobDescription",
22558+
"request": {
22559+
"method": "POST",
22560+
"header": [
22561+
{
22562+
"key": "Authorization",
22563+
"type": "text",
22564+
"value": "Bearer {{token_member}}"
22565+
},
22566+
{
22567+
"key": "Content-Type",
22568+
"type": "text",
22569+
"value": "application/json"
22570+
}
22571+
],
22572+
"body": {
22573+
"mode": "raw",
22574+
"raw": "{\n \"description\": \"nodejs react c++ hello\"\n}",
22575+
"options": {
22576+
"raw": {
22577+
"language": "json"
22578+
}
22579+
}
22580+
},
22581+
"url": {
22582+
"raw": "{{URL}}/taas-teams/getSkillsByJobDescription",
22583+
"host": [
22584+
"{{URL}}"
22585+
],
22586+
"path": [
22587+
"taas-teams",
22588+
"getSkillsByJobDescription"
22589+
]
22590+
}
22591+
},
22592+
"response": []
22593+
},
22594+
{
22595+
"name": "POST /taas-teams/email - member-issue-report",
22596+
"request": {
22597+
"method": "POST",
22598+
"header": [
22599+
{
22600+
"key": "Authorization",
22601+
"type": "text",
22602+
"value": "Bearer {{token_member}}"
22603+
},
22604+
{
22605+
"key": "Content-Type",
22606+
"type": "text",
22607+
"value": "application/json"
22608+
}
22609+
],
22610+
"body": {
22611+
"mode": "raw",
22612+
"raw": "{\n \"template\": \"member-issue-report\",\n \"data\": {\n \"projectName\": \"TaaS Project Name\",\n \"projectId\": 12345,\n \"userHandle\": \"pshah_manager\",\n \"reportText\": \"I have issue with ...\"\n }\n}",
22613+
"options": {
22614+
"raw": {
22615+
"language": "json"
2257422616
}
2257522617
],
2257622618
"request": {

docs/swagger.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,6 +3172,54 @@ paths:
31723172
application/json:
31733173
schema:
31743174
$ref: "#/components/schemas/Error"
3175+
3176+
/taas-teams/getSkillsByJobDescription:
3177+
post:
3178+
tags:
3179+
- Teams
3180+
description: |
3181+
Get skill list by Job Description
3182+
security:
3183+
- bearerAuth: []
3184+
requestBody:
3185+
content:
3186+
application/json:
3187+
schema:
3188+
$ref: "#/components/schemas/TeamJobDescriptionRequestBody"
3189+
responses:
3190+
"200":
3191+
description: OK
3192+
content:
3193+
application/json:
3194+
schema:
3195+
type : array
3196+
items : {
3197+
$ref: "#/components/schemas/SkillItem"
3198+
}
3199+
"400":
3200+
description: Bad request
3201+
content:
3202+
application/json:
3203+
schema:
3204+
$ref: "#/components/schemas/Error"
3205+
"401":
3206+
description: Not authenticated
3207+
content:
3208+
application/json:
3209+
schema:
3210+
$ref: "#/components/schemas/Error"
3211+
"403":
3212+
description: Forbidden
3213+
content:
3214+
application/json:
3215+
schema:
3216+
$ref: "#/components/schemas/Error"
3217+
"500":
3218+
description: Internal Server Error
3219+
content:
3220+
application/json:
3221+
schema:
3222+
$ref: "#/components/schemas/Error"
31753223
/taas-teams/email:
31763224
post:
31773225
tags:
@@ -3545,6 +3593,15 @@ components:
35453593
scheme: bearer
35463594
bearerFormat: JWT
35473595
schemas:
3596+
SkillItem:
3597+
properties:
3598+
tag:
3599+
type: string
3600+
type:
3601+
type: string
3602+
source:
3603+
type: string
3604+
35483605
Job:
35493606
required:
35503607
- id
@@ -5054,6 +5111,14 @@ components:
50545111
type: array
50555112
items:
50565113
$ref: "#/components/schemas/Skill"
5114+
TeamJobDescriptionRequestBody:
5115+
type: object
5116+
properties:
5117+
description:
5118+
type: string
5119+
description: "job description"
5120+
example: "nodejs and java"
5121+
50575122
TeamEmailRequestBody:
50585123
type: object
50595124
properties:

src/common/helper.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,29 @@ async function substituteStringByObject (string, object) {
17451745
return string
17461746
}
17471747

1748+
1749+
/**
1750+
* Get tags from tagging service
1751+
* @param {String} description The challenge description
1752+
* @returns {Array} array of tags
1753+
*/
1754+
async function getTags (description) {
1755+
const data = { text: description, extract_confidence: false}
1756+
const type = "emsi/internal_no_refresh"
1757+
const url = `${config.TC_API}/contest-tagging/${type}`;
1758+
const res = await request
1759+
.post(url)
1760+
.set('Accept', 'application/json')
1761+
.send(querystring.stringify(data))
1762+
1763+
localLogger.debug({
1764+
context: 'getTags',
1765+
message: `response body: ${JSON.stringify(res.body)}`,
1766+
});
1767+
return _.get(res, 'body');
1768+
}
1769+
1770+
17481771
/**
17491772
* @param {Object} currentUser the user performing the action
17501773
* @param {Object} data title of project and any other info
@@ -1806,6 +1829,7 @@ module.exports = {
18061829
getMemberDetailsByHandles,
18071830
getMemberDetailsByHandle,
18081831
getMemberDetailsByEmails,
1832+
getTags,
18091833
createProjectMember,
18101834
listProjectMembers,
18111835
listProjectMemberInvites,

src/controllers/TeamController.js

Lines changed: 13 additions & 2 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,
130-
createProj
131-
}
140+
getSkillsByJobDescription,
141+
createProj,
142+
};

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: 26 additions & 2 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,
698-
createProj
699-
}
721+
getSkillsByJobDescription,
722+
createProj,
723+
};

0 commit comments

Comments
 (0)