diff --git a/docs/Topcoder-bookings-api.postman_collection.json b/docs/Topcoder-bookings-api.postman_collection.json index 9f9c2314..fec4d0d6 100644 --- a/docs/Topcoder-bookings-api.postman_collection.json +++ b/docs/Topcoder-bookings-api.postman_collection.json @@ -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": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 40b1d474..1d036ce6 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -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: @@ -3545,6 +3593,15 @@ components: scheme: bearer bearerFormat: JWT schemas: + SkillItem: + properties: + tag: + type: string + type: + type: string + source: + type: string + Job: required: - id @@ -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: diff --git a/src/common/helper.js b/src/common/helper.js index 7fdcfd4c..a599fb65 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -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 @@ -1806,6 +1829,7 @@ module.exports = { getMemberDetailsByHandles, getMemberDetailsByHandle, getMemberDetailsByEmails, + getTags, createProjectMember, listProjectMembers, listProjectMemberInvites, diff --git a/src/controllers/TeamController.js b/src/controllers/TeamController.js index 26d70738..6afa865d 100644 --- a/src/controllers/TeamController.js +++ b/src/controllers/TeamController.js @@ -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 @@ -127,5 +137,6 @@ module.exports = { searchInvites, deleteMember, getMe, - createProj -} + getSkillsByJobDescription, + createProj, +}; diff --git a/src/routes/TeamRoutes.js b/src/routes/TeamRoutes.js index 07d777d4..21389c43 100644 --- a/src/routes/TeamRoutes.js +++ b/src/routes/TeamRoutes.js @@ -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', diff --git a/src/services/TeamService.js b/src/services/TeamService.js index 4052e942..531f8257 100644 --- a/src/services/TeamService.js +++ b/src/services/TeamService.js @@ -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 @@ -695,5 +718,6 @@ module.exports = { searchInvites, deleteMember, getMe, - createProj -} + getSkillsByJobDescription, + createProj, +};