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

Commit a117332

Browse files
committed
Merge branch 'develop'
2 parents 91a6829 + eca5e1c commit a117332

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/services/ProcessorService.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function getPlatforms (m2mToken) {
4141
*/
4242
async function getChallengeById (m2mToken, legacyId) {
4343
const response = await helper.getRequest(`${config.V4_CHALLENGE_API_URL}/${legacyId}`, m2mToken)
44-
return _.get(response, 'body.result.content[0]')
44+
return _.get(response, 'body.result.content')
4545
}
4646

4747
/**
@@ -78,6 +78,9 @@ async function parsePayload (payload, m2mToken, isCreated = true) {
7878
projectId,
7979
status: payload.status
8080
}
81+
if (payload.billingAccountId) {
82+
data.billingAccountId = payload.billingAccountId
83+
}
8184
if (_.get(payload, 'legacy.forumId')) {
8285
data.forumId = payload.legacy.forumId
8386
}
@@ -144,16 +147,11 @@ async function parsePayload (payload, m2mToken, isCreated = true) {
144147
}
145148

146149
// prize type can be Challenge prizes
147-
const challengePrizes = _.filter(payload.prizeSets, p => p.type !== constants.prizeSetTypes.ChallengePrizes)
148-
if (challengePrizes.length > 1) {
150+
const challengePrizes = _.find(payload.prizeSets, { type: constants.prizeSetTypes.ChallengePrizes })
151+
if (!challengePrizes) {
149152
throw new Error('Challenge prize information is invalid.')
150153
}
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-
}
154+
data.prizes = _.map(challengePrizes[0].prizes, 'value').sort((a, b) => b - a)
157155
}
158156
if (payload.tags) {
159157
const techResult = await getTechnologies(m2mToken)
@@ -245,6 +243,7 @@ processCreate.schema = {
245243
directProjectId: Joi.number(),
246244
forumId: Joi.number().integer().positive()
247245
}),
246+
billingAccountId: Joi.number(),
248247
name: Joi.string().required(),
249248
description: Joi.string(),
250249
privateDescription: Joi.string(),
@@ -338,6 +337,7 @@ processUpdate.schema = {
338337
forumId: Joi.number().integer().positive(),
339338
informixModified: Joi.string()
340339
}),
340+
billingAccountId: Joi.number(),
341341
typeId: Joi.string(),
342342
name: Joi.string(),
343343
description: Joi.string(),

0 commit comments

Comments
 (0)