Skip to content

Commit a65cffc

Browse files
vikasrohitmaxceem
vikasrohit
andauthored
Enriching skills without enrich Elastic.co feature (#501)
* Revert "Revert "New "Handling missing skill data enrichment via API call""" * Fixed topcoder taxonomy id * deployable feature branch Co-authored-by: maxceem <[email protected]>
1 parent 5113817 commit a65cffc

File tree

4 files changed

+39
-31
lines changed

4 files changed

+39
-31
lines changed

.circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ workflows:
6969
only:
7070
- dev
7171
- change-validatations-in-job-jc
72+
- feature/enriching-skills-data-with-api-2
7273

7374
# Production builds are exectuted only on tagged commits to the
7475
# master branch.

config/default.js

+4-2
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 || '9cc0795a-6e12-4c84-9744-15858dba1861',
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

+27-21
Original file line numberDiff line numberDiff line change
@@ -3212,7 +3212,7 @@ paths:
32123212
schema:
32133213
type: array
32143214
items:
3215-
$ref: "#/components/schemas/UbahnSkill"
3215+
$ref: "#/components/schemas/SkillInSkillsAPI"
32163216
headers:
32173217
X-Next-Page:
32183218
schema:
@@ -5574,17 +5574,25 @@ components:
55745574
type: string
55755575
example: "React"
55765576
description: The skill name.
5577-
UbahnSkill:
5578-
type: object
5577+
SkillInSkillsAPI:
5578+
required:
5579+
- "id"
5580+
- "name"
5581+
- "taxonomyId"
5582+
- "taxonomyName"
5583+
- "metadata"
55795584
properties:
55805585
id:
55815586
type: "string"
55825587
format: "UUID"
55835588
description: "The skill id"
5584-
skillProviderId:
5589+
taxonomyId:
55855590
type: "string"
55865591
format: "UUID"
5587-
description: "The referenced skill provider id"
5592+
description: "The referenced taxonomy id"
5593+
taxonomyName:
5594+
type: "string"
5595+
description: "The referenced taxonomy name"
55885596
name:
55895597
type: "string"
55905598
description: "The name of the skill"
@@ -5594,22 +5602,20 @@ components:
55945602
uri:
55955603
type: "string"
55965604
description: "The uri for the skill"
5597-
created:
5598-
type: "string"
5599-
format: "date-time"
5600-
description: "When the entity was created."
5601-
updated:
5602-
type: "string"
5603-
format: "date-time"
5604-
description: "When the entity was updated."
5605-
createdBy:
5606-
type: "string"
5607-
format: "UUID"
5608-
description: "Creator of the entity."
5609-
updatedBy:
5610-
type: "string"
5611-
format: "UUID"
5612-
description: "User that last updated the entity."
5605+
metadata:
5606+
type: "object"
5607+
description: "The metadata for the skill"
5608+
properties:
5609+
updated:
5610+
type: "string"
5611+
format: "date-time"
5612+
description: "The last updated timestamp of the skill"
5613+
challengeProminence:
5614+
type: "string"
5615+
description: "The challenge prominence ranging from [0, 1]"
5616+
memberProminence:
5617+
type: "string"
5618+
description: "The member prominence ranging from [0, 1]"
56135619
JobForTeam:
56145620
properties:
56155621
id:

src/common/helper.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ async function listUsersByExternalId (externalId) {
951951
context: 'listUserByExternalId',
952952
message: `response body: ${JSON.stringify(res.body)}`
953953
})
954+
954955
return res.body
955956
}
956957

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

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

12131212
/**
12141213
* Function to search skills from v5/skills
1215-
* - only returns skills from Topcoder Skills Provider defined by `TOPCODER_SKILL_PROVIDER_ID`
1214+
* - only returns skills from Topcoder Skills API defined by `TOPCODER_TAXONOMY_ID`
12161215
*
12171216
* @param {Object} criteria the search criteria
12181217
* @returns the request result
@@ -1221,9 +1220,9 @@ async function getTopcoderSkills (criteria) {
12211220
const token = await getM2MUbahnToken()
12221221
try {
12231222
const res = await request
1224-
.get(`${config.TC_API}/skills`)
1223+
.get(`${config.TC_BETA_API}/skills`)
12251224
.query({
1226-
skillProviderId: config.TOPCODER_SKILL_PROVIDER_ID,
1225+
taxonomyId: config.TOPCODER_TAXONOMY_ID,
12271226
...criteria
12281227
})
12291228
.set('Authorization', `Bearer ${token}`)
@@ -1249,7 +1248,7 @@ async function getTopcoderSkills (criteria) {
12491248

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

0 commit comments

Comments
 (0)