@@ -126,7 +126,7 @@ async function createUserSkill (userId, skillProviderName, skillName, certifierI
126
126
// Does the skill already exist on the user?
127
127
const existingSkill = await helper . getUbahnSingleRecord ( `/users/${ userId } /skills/${ skill . id } ` , { } , true )
128
128
129
- if ( ! existingSkill ) {
129
+ if ( ! existingSkill || ! existingSkill . id ) {
130
130
await helper . createUbahnRecord ( `/users/${ userId } /skills` , { certifierId, certifiedDate, metricValue, skillId : skill . id } )
131
131
} else {
132
132
await helper . updateUBahnRecord ( `/users/${ userId } /skills/${ skill . id } ` , { certifierId, certifiedDate, metricValue } )
@@ -153,7 +153,7 @@ async function createAchievement (userId, providerName, certifierId, certifiedDa
153
153
const achievementsProvider = await helper . getUbahnSingleRecord ( '/achievementsProviders' , { name : providerName } )
154
154
const existingAchievement = await helper . getUbahnSingleRecord ( `/users/${ userId } /achievements/${ achievementsProvider . id } ` , { } , true )
155
155
156
- if ( ! existingAchievement ) {
156
+ if ( ! existingAchievement || ! existingAchievement . id ) {
157
157
await helper . createUbahnRecord ( `/users/${ userId } /achievements` , { certifierId, certifiedDate, name, uri, achievementsProviderId : achievementsProvider . id } )
158
158
} else {
159
159
await helper . updateUBahnRecord ( `/users/${ userId } /achievements/${ achievementsProvider . id } ` , { certifierId, certifiedDate, name, uri } )
@@ -181,7 +181,7 @@ async function createUserAttributes (userId, record) {
181
181
182
182
const existingAttribute = await helper . getUbahnSingleRecord ( `/users/${ userId } /attributes/${ attribute . id } ` , { } , true )
183
183
184
- if ( ! existingAttribute ) {
184
+ if ( ! existingAttribute || ! existingAttribute . id ) {
185
185
await helper . createUbahnRecord ( `/users/${ userId } /attributes` , { attributeId : attribute . id , value } )
186
186
} else {
187
187
await helper . updateUBahnRecord ( `/users/${ userId } /attributes/${ attribute . id } ` , { value } )
0 commit comments