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

Commit cf17129

Browse files
fix issue with missing challenge prizes
1 parent b17e336 commit cf17129

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/services/ProcessorService.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,11 @@ async function parsePayload (payload, m2mToken, isCreated = true) {
144144
}
145145

146146
// prize type can be Challenge prizes
147-
const challengePrizes = _.filter(payload.prizeSets, p => p.type !== constants.prizeSetTypes.ChallengePrizes)
148-
if (challengePrizes.length > 1) {
147+
const challengePrizes = _.find(payload.prizeSets, { type: constants.prizeSetTypes.ChallengePrizes })
148+
if (!challengePrizes) {
149149
throw new Error('Challenge prize information is invalid.')
150150
}
151-
if (challengePrizes.length === 0) {
152-
// learning challenge has no prizes, for safeguard
153-
data.prizes = [0]
154-
} else {
155-
data.prizes = _.map(challengePrizes[0].prizes, 'value').sort((a, b) => b - a)
156-
}
151+
data.prizes = _.map(challengePrizes[0].prizes, 'value').sort((a, b) => b - a)
157152
}
158153
if (payload.tags) {
159154
const techResult = await getTechnologies(m2mToken)

0 commit comments

Comments
 (0)