Skip to content

Commit 0a03795

Browse files
authored
Merge pull request #496 from topcoder-platform/revert-487-feature/enriching-skills-data-with-api
Revert "Handling missing skill data enrichment via API call"
2 parents 7bd6c8c + 88d8511 commit 0a03795

File tree

3 files changed

+32
-46
lines changed

3 files changed

+32
-46
lines changed

config/default.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ 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',
3836
// the organization id
3937
ORG_ID: process.env.ORG_ID || '36ed815b-3da1-49f1-a043-aaed0a4e81ad',
40-
// the referenced taxonomy id
41-
TOPCODER_TAXONOMY_ID: process.env.TOPCODER_TAXONOMY_ID || '7637ae1a-3b7c-44eb-a5ed-10ea02f1885d',
38+
// the referenced skill provider id
39+
TOPCODER_SKILL_PROVIDER_ID: process.env.TOPCODER_SKILL_PROVIDER_ID || '9cc0795a-6e12-4c84-9744-15858dba1861',
4240

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

docs/swagger.yaml

Lines changed: 21 additions & 27 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/SkillInSkillsAPI"
3160+
$ref: "#/components/schemas/UbahnSkill"
31613161
headers:
31623162
X-Next-Page:
31633163
schema:
@@ -5516,25 +5516,17 @@ components:
55165516
type: string
55175517
example: "React"
55185518
description: The skill name.
5519-
SkillInSkillsAPI:
5520-
required:
5521-
- "id"
5522-
- "name"
5523-
- "taxonomyId"
5524-
- "taxonomyName"
5525-
- "metadata"
5519+
UbahnSkill:
5520+
type: object
55265521
properties:
55275522
id:
55285523
type: "string"
55295524
format: "UUID"
55305525
description: "The skill id"
5531-
taxonomyId:
5526+
skillProviderId:
55325527
type: "string"
55335528
format: "UUID"
5534-
description: "The referenced taxonomy id"
5535-
taxonomyName:
5536-
type: "string"
5537-
description: "The referenced taxonomy name"
5529+
description: "The referenced skill provider id"
55385530
name:
55395531
type: "string"
55405532
description: "The name of the skill"
@@ -5544,20 +5536,22 @@ components:
55445536
uri:
55455537
type: "string"
55465538
description: "The uri for the skill"
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]"
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."
55615555
JobForTeam:
55625556
properties:
55635557
id:

src/common/helper.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -950,15 +950,7 @@ async function listUsersByExternalId (externalId) {
950950
context: 'listUserByExternalId',
951951
message: `response body: ${JSON.stringify(res.body)}`
952952
})
953-
954-
const users = res.body
955-
// populate skill data for each user skill
956-
await Promise.all(users.map(user => Promise.all(user.skills.map(async userSkill => {
957-
const skill = await getSkillById(userSkill.skillId)
958-
userSkill.skill = skill
959-
}))))
960-
961-
return users
953+
return res.body
962954
}
963955

964956
/**
@@ -1100,7 +1092,9 @@ async function getUserById (userId, enrich) {
11001092
const user = _.pick(res.body, ['id', 'handle', 'firstName', 'lastName'])
11011093

11021094
if (enrich) {
1103-
user.skills = await Promise.all((res.body.skills || []).map(async (userSkill) => getSkillById(userSkill.skillId)))
1095+
user.skills = (res.body.skills || []).map((skillObj) =>
1096+
_.pick(skillObj.skill, ['id', 'name'])
1097+
)
11041098
const attributes = _.get(res, 'body.attributes', [])
11051099
user.attributes = _.map(attributes, (attr) =>
11061100
_.pick(attr, ['id', 'value', 'attribute.id', 'attribute.name'])
@@ -1217,7 +1211,7 @@ async function getProjectById (currentUser, id) {
12171211

12181212
/**
12191213
* Function to search skills from v5/skills
1220-
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
1214+
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
12211215
*
12221216
* @param {Object} criteria the search criteria
12231217
* @returns the request result
@@ -1226,9 +1220,9 @@ async function getTopcoderSkills (criteria) {
12261220
const token = await getM2MUbahnToken()
12271221
try {
12281222
const res = await request
1229-
.get(`${config.TC_BETA_API}/skills`)
1223+
.get(`${config.TC_API}/skills`)
12301224
.query({
1231-
taxonomyId: config.TOPCODER_TAXONOMY_ID,
1225+
skillProviderId: config.TOPCODER_SKILL_PROVIDER_ID,
12321226
...criteria
12331227
})
12341228
.set('Authorization', `Bearer ${token}`)
@@ -1254,7 +1248,7 @@ async function getTopcoderSkills (criteria) {
12541248

12551249
/**
12561250
* Function to search and retrive all skills from v5/skills
1257-
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
1251+
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
12581252
*
12591253
* @param {Object} criteria the search criteria
12601254
* @returns the request result
@@ -1278,7 +1272,7 @@ async function getAllTopcoderSkills (criteria) {
12781272
async function getSkillById (skillId) {
12791273
const token = await getM2MUbahnToken()
12801274
const res = await request
1281-
.get(`${config.TC_BETA_API}/skills/${skillId}`)
1275+
.get(`${config.TC_API}/skills/${skillId}`)
12821276
.set('Authorization', `Bearer ${token}`)
12831277
.set('Content-Type', 'application/json')
12841278
.set('Accept', 'application/json')

0 commit comments

Comments
 (0)