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

Commit 7486776

Browse files
Fix issue where record did not exist but processor would still try to update it instead of creating it
1 parent 4c58da1 commit 7486776

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/services/ProcessorService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function createUserSkill (userId, skillProviderName, skillName, certifierI
126126
// Does the skill already exist on the user?
127127
const existingSkill = await helper.getUbahnSingleRecord(`/users/${userId}/skills/${skill.id}`, {}, true)
128128

129-
if (!existingSkill) {
129+
if (!existingSkill || !existingSkill.id) {
130130
await helper.createUbahnRecord(`/users/${userId}/skills`, { certifierId, certifiedDate, metricValue, skillId: skill.id })
131131
} else {
132132
await helper.updateUBahnRecord(`/users/${userId}/skills/${skill.id}`, { certifierId, certifiedDate, metricValue })
@@ -153,7 +153,7 @@ async function createAchievement (userId, providerName, certifierId, certifiedDa
153153
const achievementsProvider = await helper.getUbahnSingleRecord('/achievementsProviders', { name: providerName })
154154
const existingAchievement = await helper.getUbahnSingleRecord(`/users/${userId}/achievements/${achievementsProvider.id}`, {}, true)
155155

156-
if (!existingAchievement) {
156+
if (!existingAchievement || !existingAchievement.id) {
157157
await helper.createUbahnRecord(`/users/${userId}/achievements`, { certifierId, certifiedDate, name, uri, achievementsProviderId: achievementsProvider.id })
158158
} else {
159159
await helper.updateUBahnRecord(`/users/${userId}/achievements/${achievementsProvider.id}`, { certifierId, certifiedDate, name, uri })
@@ -181,7 +181,7 @@ async function createUserAttributes (userId, record) {
181181

182182
const existingAttribute = await helper.getUbahnSingleRecord(`/users/${userId}/attributes/${attribute.id}`, {}, true)
183183

184-
if (!existingAttribute) {
184+
if (!existingAttribute || !existingAttribute.id) {
185185
await helper.createUbahnRecord(`/users/${userId}/attributes`, { attributeId: attribute.id, value })
186186
} else {
187187
await helper.updateUBahnRecord(`/users/${userId}/attributes/${attribute.id}`, { value })

0 commit comments

Comments
 (0)