@@ -11,13 +11,13 @@ const helper = require('./src/common/helper')
11
11
* @param {String } userId the userId
12
12
* @param {String } tagId the tag id
13
13
* @param {Number } score the skill score
14
- * @param {String } skillProviderId the skillProvider id
14
+ * @param {String } taxonomyId the taxonomy id
15
15
* @param {boolean } isDelete if delete the skill
16
16
* @returns {Promise }
17
17
*/
18
- async function syncUserSkill ( userId , tagId , score , skillProviderId , isDelete ) {
18
+ async function syncUserSkill ( userId , tagId , score , taxonomyId , isDelete ) {
19
19
const name = await helper . getTagName ( tagId )
20
- const skill = await helper . getUbahnResource ( 'skills' , { skillProviderId , name } )
20
+ const skill = await helper . getUbahnResource ( 'skills' , { taxonomyId , name } )
21
21
const skillExist = await helper . checkUserSkillExist ( userId , skill . id )
22
22
if ( isDelete && skillExist ) {
23
23
helper . deleteUserSkill ( userId , skill . id )
@@ -35,7 +35,7 @@ async function syncUserSkill(userId, tagId, score, skillProviderId, isDelete) {
35
35
module . exports . handle = async ( event ) => {
36
36
try {
37
37
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 } )
39
39
for ( const record of event . Records ) {
40
40
try {
41
41
const handle = _ . get ( record , 'dynamodb.NewImage.userHandle.S' )
@@ -53,15 +53,15 @@ module.exports.handle = async (event) => {
53
53
console . log ( 'Skills to delete:' , JSON . stringify ( deleteSkills ) )
54
54
const user = await helper . getUser ( handle )
55
55
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 )
57
57
await helper . sleep ( )
58
58
}
59
59
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 )
61
61
await helper . sleep ( )
62
62
}
63
63
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 )
65
65
await helper . sleep ( )
66
66
}
67
67
} catch ( e ) {
0 commit comments