Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 3e2dba1

Browse files
committed
no taxonomy for tc skills
1 parent 4bb7417 commit 3e2dba1

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

src/modules/tcskill/service.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const dbHelper = require('../../common/db-helper')
1111
const sequelize = require('../../models/index')
1212

1313
const TCSkill = sequelize.models.TCSkill
14-
const Taxonomy = sequelize.models.Taxonomy
1514

1615
/**
1716
* get skill by id
@@ -28,7 +27,6 @@ async function get (id, params, query = {}) {
2827
throw errors.newEntityNotFoundError(`cannot find ${TCSkill.name} where ${_.map(trueParams, (v, k) => `${k}:${v}`).join(', ')}`)
2928
}
3029
const skill = recordObj.dataValues
31-
await populateTaxonomyNames(skill)
3230

3331
return helper.omitAuditFields(skill)
3432
}
@@ -38,32 +36,6 @@ get.schema = {
3836
params: joi.object()
3937
}
4038

41-
/**
42-
* Populates the taxonomy name for each of the skill
43-
* @param skills individual skill or an array of skills
44-
* @returns the updated skills object
45-
*/
46-
async function populateTaxonomyNames (skills) {
47-
if (_.isArray(skills)) {
48-
const taxonomyMap = {}
49-
for (const skill of skills) {
50-
// dont populate if we already have the name
51-
if (skill.taxonomyName) { continue }
52-
53-
if (!_.has(taxonomyMap, skill.taxonomyId)) {
54-
const taxonomy = await dbHelper.get(Taxonomy, skill.taxonomyId)
55-
taxonomyMap[skill.taxonomyId] = taxonomy.name
56-
}
57-
skill.taxonomyName = taxonomyMap[skill.taxonomyId]
58-
}
59-
} else {
60-
const taxonomy = await dbHelper.get(Taxonomy, skills.taxonomyId)
61-
skills.taxonomyName = taxonomy.name
62-
}
63-
64-
return skills
65-
}
66-
6739
/**
6840
* search skills by query
6941
* @param query the search query
@@ -73,7 +45,6 @@ async function search (query) {
7345
let items = await dbHelper.find(TCSkill, query)
7446

7547
items = items.map(item => item.dataValues)
76-
await populateTaxonomyNames(items)
7748
items = helper.omitAuditFields(items)
7849
return { fromDb: true, result: items, total: items.length }
7950
}

0 commit comments

Comments
 (0)