@@ -116,6 +116,9 @@ async function getUserId (user) {
116
116
async function createUserSkill ( userId , skillProviderName , skillName , certifierId , certifiedDate , metricValue ) {
117
117
if ( ( ! skillProviderName || ! skillName ) && ( certifierId || certifiedDate || metricValue ) ) {
118
118
throw Error ( `Skill provider or skill name is missing for user with id ${ userId } ` )
119
+ } else if ( ! skillProviderName || ! skillName ) {
120
+ // Empty values. Ignore.
121
+ return
119
122
}
120
123
const skillProvider = await helper . getUbahnSingleRecord ( '/skillsProviders' , { name : skillProviderName } )
121
124
const skill = await helper . getUbahnSingleRecord ( '/skills' , { skillProviderId : skillProvider . id , name : skillName } )
@@ -135,6 +138,9 @@ async function createUserSkill (userId, skillProviderName, skillName, certifierI
135
138
async function createAchievement ( userId , providerName , certifierId , certifiedDate , name , uri ) {
136
139
if ( ! providerName && ( certifierId || certifiedDate || name || uri ) ) {
137
140
throw Error ( `Achievement provider name is missing for user with id ${ userId } ` )
141
+ } else if ( ! providerName ) {
142
+ // Empty values. Ignore.
143
+ return
138
144
}
139
145
const achievementsProvider = await helper . getUbahnSingleRecord ( '/achievementsProviders' , { name : providerName } )
140
146
await helper . createUbahnRecord ( `/users/${ userId } /achievements` , { certifierId, certifiedDate, name, uri, achievementsProviderId : achievementsProvider . id } )
@@ -151,6 +157,9 @@ async function createUserAttributes (userId, record) {
151
157
while ( record [ `attributeValue${ i } ` ] ) {
152
158
if ( ( ! record [ `attributeGroupName${ i } ` ] || ! record [ `attributeName${ i } ` ] ) && record [ `attributeValue${ i } ` ] ) {
153
159
throw Error ( `Attribute group name or attribute name is missing for user with id ${ userId } and with attribute value ${ record [ `attributeValue${ i } ` ] } ` )
160
+ } else if ( ! record [ `attributeGroupName${ i } ` ] || ! record [ `attributeName${ i } ` ] ) {
161
+ // Empty values. Ignore.
162
+ return
154
163
}
155
164
const attributeGroup = await helper . getUbahnSingleRecord ( '/attributeGroups' , { name : record [ `attributeGroupName${ i } ` ] } )
156
165
const attribute = await helper . getUbahnSingleRecord ( '/attributes' , { attributeGroupId : attributeGroup . id , name : record [ `attributeName${ i } ` ] } )
0 commit comments