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

Commit b5cd875

Browse files
author
vikasrohit
authored
Adapting for new V5 skills api
1 parent 782d06e commit b5cd875

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ const helper = require('./src/common/helper')
1111
* @param {String} userId the userId
1212
* @param {String} tagId the tag id
1313
* @param {Number} score the skill score
14-
* @param {String} skillProviderId the skillProvider id
14+
* @param {String} taxonomyId the taxonomy id
1515
* @param {boolean} isDelete if delete the skill
1616
* @returns {Promise}
1717
*/
18-
async function syncUserSkill(userId, tagId, score, skillProviderId, isDelete) {
18+
async function syncUserSkill(userId, tagId, score, taxonomyId, isDelete) {
1919
const name = await helper.getTagName(tagId)
20-
const skill = await helper.getUbahnResource('skills', { skillProviderId, name })
20+
const skill = await helper.getUbahnResource('skills', { taxonomyId, name })
2121
const skillExist = await helper.checkUserSkillExist(userId, skill.id)
2222
if (isDelete && skillExist) {
2323
helper.deleteUserSkill(userId, skill.id)
@@ -35,7 +35,7 @@ async function syncUserSkill(userId, tagId, score, skillProviderId, isDelete) {
3535
module.exports.handle = async (event) => {
3636
try {
3737
console.log(`Received event: `, JSON.stringify(event))
38-
const skillProvider = await helper.getUbahnResource('skillsProviders', { name: config.SKILL_PROVIDER_NAME })
38+
const taxonomy = await helper.getUbahnResource('taxonomies', { name: config.TAXONOMY_NAME })
3939
for (const record of event.Records) {
4040
try {
4141
const handle = _.get(record, 'dynamodb.NewImage.userHandle.S')
@@ -53,15 +53,15 @@ module.exports.handle = async (event) => {
5353
console.log('Skills to delete:', JSON.stringify(deleteSkills))
5454
const user = await helper.getUser(handle)
5555
for (const key of _.keys(createSkills)) {
56-
await syncUserSkill(user.id, key, _.get(createSkills,`${key}.score`, 0), skillProvider.id)
56+
await syncUserSkill(user.id, key, _.get(createSkills,`${key}.score`, 0), taxonomy.id)
5757
await helper.sleep()
5858
}
5959
for (const key of _.keys(updateSkills)) {
60-
await syncUserSkill(user.id, key, _.get(createSkills,`${key}.score`, 0), skillProvider.id)
60+
await syncUserSkill(user.id, key, _.get(createSkills,`${key}.score`, 0), taxonomy.id)
6161
await helper.sleep()
6262
}
6363
for (const key of _.keys(deleteSkills)) {
64-
await syncUserSkill(user.id, key, 0, skillProvider.id, true)
64+
await syncUserSkill(user.id, key, 0, taxonomy.id, true)
6565
await helper.sleep()
6666
}
6767
} catch (e) {

0 commit comments

Comments
 (0)