Skip to content

Revert "Handling missing skill data enrichment via API call" #496

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 1 commit into from
Aug 16, 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
6 changes: 2 additions & 4 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ module.exports = {

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

TOPCODER_USERS_API: process.env.TOPCODER_USERS_API || 'https://api.topcoder-dev.com/v3/users',
// the api to find topcoder members
Expand Down
48 changes: 21 additions & 27 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3157,7 +3157,7 @@ paths:
schema:
type: array
items:
$ref: "#/components/schemas/SkillInSkillsAPI"
$ref: "#/components/schemas/UbahnSkill"
headers:
X-Next-Page:
schema:
Expand Down Expand Up @@ -5516,25 +5516,17 @@ components:
type: string
example: "React"
description: The skill name.
SkillInSkillsAPI:
required:
- "id"
- "name"
- "taxonomyId"
- "taxonomyName"
- "metadata"
UbahnSkill:
type: object
properties:
id:
type: "string"
format: "UUID"
description: "The skill id"
taxonomyId:
skillProviderId:
type: "string"
format: "UUID"
description: "The referenced taxonomy id"
taxonomyName:
type: "string"
description: "The referenced taxonomy name"
description: "The referenced skill provider id"
name:
type: "string"
description: "The name of the skill"
Expand All @@ -5544,20 +5536,22 @@ components:
uri:
type: "string"
description: "The uri for the skill"
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]"
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."
JobForTeam:
properties:
id:
Expand Down
24 changes: 9 additions & 15 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,15 +950,7 @@ async function listUsersByExternalId (externalId) {
context: 'listUserByExternalId',
message: `response body: ${JSON.stringify(res.body)}`
})

const users = res.body
// populate skill data for each user skill
await Promise.all(users.map(user => Promise.all(user.skills.map(async userSkill => {
const skill = await getSkillById(userSkill.skillId)
userSkill.skill = skill
}))))

return users
return res.body
}

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

if (enrich) {
user.skills = await Promise.all((res.body.skills || []).map(async (userSkill) => getSkillById(userSkill.skillId)))
user.skills = (res.body.skills || []).map((skillObj) =>
_.pick(skillObj.skill, ['id', 'name'])
)
const attributes = _.get(res, 'body.attributes', [])
user.attributes = _.map(attributes, (attr) =>
_.pick(attr, ['id', 'value', 'attribute.id', 'attribute.name'])
Expand Down Expand Up @@ -1217,7 +1211,7 @@ async function getProjectById (currentUser, id) {

/**
* Function to search skills from v5/skills
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
*
* @param {Object} criteria the search criteria
* @returns the request result
Expand All @@ -1226,9 +1220,9 @@ async function getTopcoderSkills (criteria) {
const token = await getM2MUbahnToken()
try {
const res = await request
.get(`${config.TC_BETA_API}/skills`)
.get(`${config.TC_API}/skills`)
.query({
taxonomyId: config.TOPCODER_TAXONOMY_ID,
skillProviderId: config.TOPCODER_SKILL_PROVIDER_ID,
...criteria
})
.set('Authorization', `Bearer ${token}`)
Expand All @@ -1254,7 +1248,7 @@ async function getTopcoderSkills (criteria) {

/**
* Function to search and retrive all skills from v5/skills
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
*
* @param {Object} criteria the search criteria
* @returns the request result
Expand All @@ -1278,7 +1272,7 @@ async function getAllTopcoderSkills (criteria) {
async function getSkillById (skillId) {
const token = await getM2MUbahnToken()
const res = await request
.get(`${config.TC_BETA_API}/skills/${skillId}`)
.get(`${config.TC_API}/skills/${skillId}`)
.set('Authorization', `Bearer ${token}`)
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
Expand Down