From 2ec15634586c0925afbbd5b34ab96802f9cadfe6 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Tue, 10 Aug 2021 07:53:12 +0530 Subject: [PATCH 1/3] skills restructure --- config/default.js | 4 ++-- docs/swagger.yaml | 48 +++++++++++++++++++++++++------------------- src/common/helper.js | 10 +++------ 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/config/default.js b/config/default.js index cb589290..492331df 100644 --- a/config/default.js +++ b/config/default.js @@ -35,8 +35,8 @@ module.exports = { TC_API: process.env.TC_API || 'https://api.topcoder-dev.com/v5', // the organization id ORG_ID: process.env.ORG_ID || '36ed815b-3da1-49f1-a043-aaed0a4e81ad', - // the referenced skill provider id - TOPCODER_SKILL_PROVIDER_ID: process.env.TOPCODER_SKILL_PROVIDER_ID || '9cc0795a-6e12-4c84-9744-15858dba1861', + // the referenced taxonomy id + TOPCODER_TAXONOMY_ID: process.env.TOPCODER_TAXONOMY_ID || '7637ae1a-3b7c-44eb-a5ed-10ea02f1885d', TOPCODER_USERS_API: process.env.TOPCODER_USERS_API || 'https://api.topcoder-dev.com/v3/users', // the api to find topcoder members diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 65d420f1..6a19225f 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3157,7 +3157,7 @@ paths: schema: type: array items: - $ref: "#/components/schemas/UbahnSkill" + $ref: "#/components/schemas/SkillInSkillsAPI" headers: X-Next-Page: schema: @@ -5319,17 +5319,25 @@ components: type: string example: "React" description: The skill name. - UbahnSkill: - type: object + SkillInSkillsAPI: + required: + - "id" + - "name" + - "taxonomyId" + - "taxonomyName" + - "metadata" properties: id: type: "string" format: "UUID" description: "The skill id" - skillProviderId: + taxonomyId: type: "string" format: "UUID" - description: "The referenced skill provider id" + description: "The referenced taxonomy id" + taxonomyName: + type: "string" + description: "The referenced taxonomy name" name: type: "string" description: "The name of the skill" @@ -5339,22 +5347,20 @@ components: uri: type: "string" description: "The uri for the skill" - created: - type: "string" - format: "date-time" - description: "When the entity was created." - updated: - type: "string" - format: "date-time" - description: "When the entity was updated." - createdBy: - type: "string" - format: "UUID" - description: "Creator of the entity." - updatedBy: - type: "string" - format: "UUID" - description: "User that last updated the entity." + metadata: + type: "object" + description: "The metadata for the skill" + properties: + updated: + type: "string" + format: "date-time" + description: "The last updated timestamp of the skill" + challengeProminence: + type: "string" + description: "The challenge prominence ranging from [0, 1]" + memberProminence: + type: "string" + description: "The member prominence ranging from [0, 1]" JobForTeam: properties: id: diff --git a/src/common/helper.js b/src/common/helper.js index 7f9625be..fa92cb1e 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -1201,21 +1201,19 @@ async function getProjectById (currentUser, id) { /** * Function to search skills from v5/skills - * - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID` + * - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID` * * @param {Object} criteria the search criteria * @returns the request result */ async function getTopcoderSkills (criteria) { - const token = await getM2MUbahnToken() try { const res = await request .get(`${config.TC_API}/skills`) .query({ - skillProviderId: config.TOPCODER_SKILL_PROVIDER_ID, + taxonomyId: config.TOPCODER_TAXONOMY_ID, ...criteria }) - .set('Authorization', `Bearer ${token}`) .set('Content-Type', 'application/json') .set('Accept', 'application/json') localLogger.debug({ @@ -1238,7 +1236,7 @@ async function getTopcoderSkills (criteria) { /** * Function to search and retrive all skills from v5/skills - * - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID` + * - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID` * * @param {Object} criteria the search criteria * @returns the request result @@ -1260,10 +1258,8 @@ async function getAllTopcoderSkills (criteria) { * @returns the request result */ async function getSkillById (skillId) { - const token = await getM2MUbahnToken() const res = await request .get(`${config.TC_API}/skills/${skillId}`) - .set('Authorization', `Bearer ${token}`) .set('Content-Type', 'application/json') .set('Accept', 'application/json') localLogger.debug({ From f885e9470b0f07a174be31934b69fec04c693165 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Tue, 10 Aug 2021 09:21:45 +0530 Subject: [PATCH 2/3] skills restructuring --- config/default.js | 4 ++-- docs/swagger.yaml | 48 +++++++++++++++++++++++++------------------- src/common/helper.js | 10 ++++----- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/config/default.js b/config/default.js index cb589290..492331df 100644 --- a/config/default.js +++ b/config/default.js @@ -35,8 +35,8 @@ module.exports = { TC_API: process.env.TC_API || 'https://api.topcoder-dev.com/v5', // the organization id ORG_ID: process.env.ORG_ID || '36ed815b-3da1-49f1-a043-aaed0a4e81ad', - // the referenced skill provider id - TOPCODER_SKILL_PROVIDER_ID: process.env.TOPCODER_SKILL_PROVIDER_ID || '9cc0795a-6e12-4c84-9744-15858dba1861', + // the referenced taxonomy id + TOPCODER_TAXONOMY_ID: process.env.TOPCODER_TAXONOMY_ID || '7637ae1a-3b7c-44eb-a5ed-10ea02f1885d', TOPCODER_USERS_API: process.env.TOPCODER_USERS_API || 'https://api.topcoder-dev.com/v3/users', // the api to find topcoder members diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 65d420f1..6a19225f 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3157,7 +3157,7 @@ paths: schema: type: array items: - $ref: "#/components/schemas/UbahnSkill" + $ref: "#/components/schemas/SkillInSkillsAPI" headers: X-Next-Page: schema: @@ -5319,17 +5319,25 @@ components: type: string example: "React" description: The skill name. - UbahnSkill: - type: object + SkillInSkillsAPI: + required: + - "id" + - "name" + - "taxonomyId" + - "taxonomyName" + - "metadata" properties: id: type: "string" format: "UUID" description: "The skill id" - skillProviderId: + taxonomyId: type: "string" format: "UUID" - description: "The referenced skill provider id" + description: "The referenced taxonomy id" + taxonomyName: + type: "string" + description: "The referenced taxonomy name" name: type: "string" description: "The name of the skill" @@ -5339,22 +5347,20 @@ components: uri: type: "string" description: "The uri for the skill" - created: - type: "string" - format: "date-time" - description: "When the entity was created." - updated: - type: "string" - format: "date-time" - description: "When the entity was updated." - createdBy: - type: "string" - format: "UUID" - description: "Creator of the entity." - updatedBy: - type: "string" - format: "UUID" - description: "User that last updated the entity." + metadata: + type: "object" + description: "The metadata for the skill" + properties: + updated: + type: "string" + format: "date-time" + description: "The last updated timestamp of the skill" + challengeProminence: + type: "string" + description: "The challenge prominence ranging from [0, 1]" + memberProminence: + type: "string" + description: "The member prominence ranging from [0, 1]" JobForTeam: properties: id: diff --git a/src/common/helper.js b/src/common/helper.js index 7f9625be..db86381d 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -1201,18 +1201,18 @@ async function getProjectById (currentUser, id) { /** * Function to search skills from v5/skills - * - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID` + * - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID` * * @param {Object} criteria the search criteria * @returns the request result */ async function getTopcoderSkills (criteria) { - const token = await getM2MUbahnToken() + const token = await getM2MToken() try { const res = await request .get(`${config.TC_API}/skills`) .query({ - skillProviderId: config.TOPCODER_SKILL_PROVIDER_ID, + taxonomyId: config.TOPCODER_TAXONOMY_ID, ...criteria }) .set('Authorization', `Bearer ${token}`) @@ -1238,7 +1238,7 @@ async function getTopcoderSkills (criteria) { /** * Function to search and retrive all skills from v5/skills - * - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID` + * - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID` * * @param {Object} criteria the search criteria * @returns the request result @@ -1260,7 +1260,7 @@ async function getAllTopcoderSkills (criteria) { * @returns the request result */ async function getSkillById (skillId) { - const token = await getM2MUbahnToken() + const token = await getM2MToken() const res = await request .get(`${config.TC_API}/skills/${skillId}`) .set('Authorization', `Bearer ${token}`) From ed21a128323965deda8ca3a652115a50a8ad52c3 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Tue, 10 Aug 2021 09:31:35 +0530 Subject: [PATCH 3/3] token fix --- src/common/helper.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/helper.js b/src/common/helper.js index dfccd2f6..f6180164 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -1221,6 +1221,7 @@ async function getTopcoderSkills (criteria) { try { const res = await request .get(`${config.TC_API}/skills`) + .set('Authorization', `Bearer ${token}`) .query({ taxonomyId: config.TOPCODER_TAXONOMY_ID, ...criteria @@ -1272,6 +1273,7 @@ async function getSkillById (skillId) { const token = await getM2MToken() const res = await request .get(`${config.TC_API}/skills/${skillId}`) + .set('Authorization', `Bearer ${token}`) .set('Content-Type', 'application/json') .set('Accept', 'application/json') localLogger.debug({