Skip to content

Commit 16cc100

Browse files
authored
Merge pull request #497 from topcoder-platform/revert-496-revert-487-feature/enriching-skills-data-with-api
New "Handling missing skill data enrichment via API call"
2 parents 11fe5f1 + 1ee0442 commit 16cc100

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

config/default.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ module.exports = {
3333

3434
// the Topcoder v5 url
3535
TC_API: process.env.TC_API || 'https://api.topcoder-dev.com/v5',
36+
// the Topcoder Beta API url currently v5.1
37+
TC_BETA_API: process.env.TC_BETA_API || 'https://api.topcoder-dev.com/v5.1',
3638
// the organization id
3739
ORG_ID: process.env.ORG_ID || '36ed815b-3da1-49f1-a043-aaed0a4e81ad',
38-
// the referenced skill provider id
39-
TOPCODER_SKILL_PROVIDER_ID: process.env.TOPCODER_SKILL_PROVIDER_ID || '9cc0795a-6e12-4c84-9744-15858dba1861',
40+
// the referenced taxonomy id
41+
TOPCODER_TAXONOMY_ID: process.env.TOPCODER_TAXONOMY_ID || '7637ae1a-3b7c-44eb-a5ed-10ea02f1885d',
4042

4143
TOPCODER_USERS_API: process.env.TOPCODER_USERS_API || 'https://api.topcoder-dev.com/v3/users',
4244
// the api to find topcoder members

docs/swagger.yaml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,7 @@ paths:
31573157
schema:
31583158
type: array
31593159
items:
3160-
$ref: "#/components/schemas/UbahnSkill"
3160+
$ref: "#/components/schemas/SkillInSkillsAPI"
31613161
headers:
31623162
X-Next-Page:
31633163
schema:
@@ -5516,17 +5516,25 @@ components:
55165516
type: string
55175517
example: "React"
55185518
description: The skill name.
5519-
UbahnSkill:
5520-
type: object
5519+
SkillInSkillsAPI:
5520+
required:
5521+
- "id"
5522+
- "name"
5523+
- "taxonomyId"
5524+
- "taxonomyName"
5525+
- "metadata"
55215526
properties:
55225527
id:
55235528
type: "string"
55245529
format: "UUID"
55255530
description: "The skill id"
5526-
skillProviderId:
5531+
taxonomyId:
55275532
type: "string"
55285533
format: "UUID"
5529-
description: "The referenced skill provider id"
5534+
description: "The referenced taxonomy id"
5535+
taxonomyName:
5536+
type: "string"
5537+
description: "The referenced taxonomy name"
55305538
name:
55315539
type: "string"
55325540
description: "The name of the skill"
@@ -5536,22 +5544,20 @@ components:
55365544
uri:
55375545
type: "string"
55385546
description: "The uri for the skill"
5539-
created:
5540-
type: "string"
5541-
format: "date-time"
5542-
description: "When the entity was created."
5543-
updated:
5544-
type: "string"
5545-
format: "date-time"
5546-
description: "When the entity was updated."
5547-
createdBy:
5548-
type: "string"
5549-
format: "UUID"
5550-
description: "Creator of the entity."
5551-
updatedBy:
5552-
type: "string"
5553-
format: "UUID"
5554-
description: "User that last updated the entity."
5547+
metadata:
5548+
type: "object"
5549+
description: "The metadata for the skill"
5550+
properties:
5551+
updated:
5552+
type: "string"
5553+
format: "date-time"
5554+
description: "The last updated timestamp of the skill"
5555+
challengeProminence:
5556+
type: "string"
5557+
description: "The challenge prominence ranging from [0, 1]"
5558+
memberProminence:
5559+
type: "string"
5560+
description: "The member prominence ranging from [0, 1]"
55555561
JobForTeam:
55565562
properties:
55575563
id:

src/common/helper.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ async function listUsersByExternalId (externalId) {
950950
context: 'listUserByExternalId',
951951
message: `response body: ${JSON.stringify(res.body)}`
952952
})
953+
953954
return res.body
954955
}
955956

@@ -1092,9 +1093,7 @@ async function getUserById (userId, enrich) {
10921093
const user = _.pick(res.body, ['id', 'handle', 'firstName', 'lastName'])
10931094

10941095
if (enrich) {
1095-
user.skills = (res.body.skills || []).map((skillObj) =>
1096-
_.pick(skillObj.skill, ['id', 'name'])
1097-
)
1096+
user.skills = await Promise.all((res.body.skills || []).map(async (userSkill) => getSkillById(userSkill.skillId)))
10981097
const attributes = _.get(res, 'body.attributes', [])
10991098
user.attributes = _.map(attributes, (attr) =>
11001099
_.pick(attr, ['id', 'value', 'attribute.id', 'attribute.name'])
@@ -1211,7 +1210,7 @@ async function getProjectById (currentUser, id) {
12111210

12121211
/**
12131212
* Function to search skills from v5/skills
1214-
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
1213+
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
12151214
*
12161215
* @param {Object} criteria the search criteria
12171216
* @returns the request result
@@ -1220,9 +1219,9 @@ async function getTopcoderSkills (criteria) {
12201219
const token = await getM2MUbahnToken()
12211220
try {
12221221
const res = await request
1223-
.get(`${config.TC_API}/skills`)
1222+
.get(`${config.TC_BETA_API}/skills`)
12241223
.query({
1225-
skillProviderId: config.TOPCODER_SKILL_PROVIDER_ID,
1224+
taxonomyId: config.TOPCODER_TAXONOMY_ID,
12261225
...criteria
12271226
})
12281227
.set('Authorization', `Bearer ${token}`)
@@ -1248,7 +1247,7 @@ async function getTopcoderSkills (criteria) {
12481247

12491248
/**
12501249
* Function to search and retrive all skills from v5/skills
1251-
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
1250+
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
12521251
*
12531252
* @param {Object} criteria the search criteria
12541253
* @returns the request result
@@ -1272,7 +1271,7 @@ async function getAllTopcoderSkills (criteria) {
12721271
async function getSkillById (skillId) {
12731272
const token = await getM2MUbahnToken()
12741273
const res = await request
1275-
.get(`${config.TC_API}/skills/${skillId}`)
1274+
.get(`${config.TC_BETA_API}/skills/${skillId}`)
12761275
.set('Authorization', `Bearer ${token}`)
12771276
.set('Content-Type', 'application/json')
12781277
.set('Accept', 'application/json')

0 commit comments

Comments
 (0)