Skip to content

Feature/role jd #287

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
merged 3 commits into from
Jun 2, 2021
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
76 changes: 59 additions & 17 deletions docs/Topcoder-bookings-api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -22554,23 +22554,65 @@
]
},
{
"name": "Delete Role",
"item": [
{
"name": "delete role with connect user",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 403', function () {\r",
" pm.response.to.have.status(403);\r",
" const response = pm.response.json()\r",
" pm.expect(response.message).to.eq(\"You are not allowed to perform this action!\")\r",
"});"
],
"type": "text/javascript"
}
"name": "POST /taas-teams/getSkillsByJobDescription",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_member}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"description\": \"nodejs react c++ hello\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{URL}}/taas-teams/getSkillsByJobDescription",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
"getSkillsByJobDescription"
]
}
},
"response": []
},
{
"name": "POST /taas-teams/email - member-issue-report",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_member}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"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}",
"options": {
"raw": {
"language": "json"
}
],
"request": {
Expand Down
65 changes: 65 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,54 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Error"

/taas-teams/getSkillsByJobDescription:
post:
tags:
- Teams
description: |
Get skill list by Job Description
security:
- bearerAuth: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/TeamJobDescriptionRequestBody"
responses:
"200":
description: OK
content:
application/json:
schema:
type : array
items : {
$ref: "#/components/schemas/SkillItem"
}
"400":
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"401":
description: Not authenticated
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"403":
description: Forbidden
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/taas-teams/email:
post:
tags:
Expand Down Expand Up @@ -3545,6 +3593,15 @@ components:
scheme: bearer
bearerFormat: JWT
schemas:
SkillItem:
properties:
tag:
type: string
type:
type: string
source:
type: string

Job:
required:
- id
Expand Down Expand Up @@ -5054,6 +5111,14 @@ components:
type: array
items:
$ref: "#/components/schemas/Skill"
TeamJobDescriptionRequestBody:
type: object
properties:
description:
type: string
description: "job description"
example: "nodejs and java"

TeamEmailRequestBody:
type: object
properties:
Expand Down
24 changes: 24 additions & 0 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,29 @@ async function substituteStringByObject (string, object) {
return string
}


/**
* Get tags from tagging service
* @param {String} description The challenge description
* @returns {Array} array of tags
*/
async function getTags (description) {
const data = { text: description, extract_confidence: false}
const type = "emsi/internal_no_refresh"
const url = `${config.TC_API}/contest-tagging/${type}`;
const res = await request
.post(url)
.set('Accept', 'application/json')
.send(querystring.stringify(data))

localLogger.debug({
context: 'getTags',
message: `response body: ${JSON.stringify(res.body)}`,
});
return _.get(res, 'body');
}


/**
* @param {Object} currentUser the user performing the action
* @param {Object} data title of project and any other info
Expand Down Expand Up @@ -1806,6 +1829,7 @@ module.exports = {
getMemberDetailsByHandles,
getMemberDetailsByHandle,
getMemberDetailsByEmails,
getTags,
createProjectMember,
listProjectMembers,
listProjectMemberInvites,
Expand Down
15 changes: 13 additions & 2 deletions src/controllers/TeamController.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ async function getMe (req, res) {
res.send(await service.getMe(req.authUser))
}


/**
* Return skills by job description.
* @param req the request
* @param res the response
*/
async function getSkillsByJobDescription(req, res) {
res.send(await service.getSkillsByJobDescription(req.authUser, req.body));
}

/**
*
* @param req the request
Expand All @@ -127,5 +137,6 @@ module.exports = {
searchInvites,
deleteMember,
getMe,
createProj
}
getSkillsByJobDescription,
createProj,
};
8 changes: 8 additions & 0 deletions src/routes/TeamRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ module.exports = {
scopes: [constants.Scopes.READ_TAAS_TEAM]
}
},
'/taas-teams/getSkillsByJobDescription': {
post: {
controller: 'TeamController',
method: 'getSkillsByJobDescription',
auth: 'jwt',
scopes: [constants.Scopes.READ_TAAS_TEAM],
},
},
'/taas-teams/:id': {
get: {
controller: 'TeamController',
Expand Down
28 changes: 26 additions & 2 deletions src/services/TeamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,29 @@ getMe.schema = Joi.object()
})
.required()

/**
* Return skills by job description.
*
* @param {Object} currentUser the user who perform this operation.
* @params {Object} criteria the search criteria
* @returns {Object} the user data for current user
*/
async function getSkillsByJobDescription(currentUser,data) {
return helper.getTags(data.description)
}

getSkillsByJobDescription.schema = Joi.object()
.keys({
currentUser: Joi.object().required(),
data: Joi.object()
.keys({
description: Joi.string().required(),
})
.required(),
})
.required();


/**
* @param {Object} currentUser the user performing the operation.
* @param {Object} data project data
Expand All @@ -695,5 +718,6 @@ module.exports = {
searchInvites,
deleteMember,
getMe,
createProj
}
getSkillsByJobDescription,
createProj,
};