Skip to content

Commit 641c848

Browse files
committed
Merge branch 'fix/overview' into fix/schema
2 parents b153a1a + b3bcc93 commit 641c848

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

src/common/challenge-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class ChallengeHelper {
365365
}
366366
});
367367
});
368-
if (overview && overview.totalPrizesInCents) {
368+
if (overview && !_.isUndefined(overview.totalPrizesInCents)) {
369369
overview.totalPrizes = overview.totalPrizesInCents / 100;
370370
delete overview.totalPrizesInCents;
371371
}

src/services/ChallengeService.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,6 @@ async function getChallenge(currentUser, id, checkIfExists) {
12831283
if (challenge.status !== constants.challengeStatuses.Completed) {
12841284
_.unset(challenge, "winners");
12851285
}
1286-
convertPrizeSetValuesToDollars(challenge.prizeSets, challenge.overview);
12871286

12881287
return challenge;
12891288
}
@@ -1410,6 +1409,7 @@ async function validateWinners(winners, challengeId) {
14101409
*/
14111410
async function updateChallenge(currentUser, challengeId, data) {
14121411
const challenge = await challengeDomain.lookup(getLookupCriteria("id", challengeId));
1412+
convertPrizeSetValuesToDollars(challenge.prizeSets, challenge.overview);
14131413

14141414
const projectId = _.get(challenge, "projectId");
14151415

@@ -1641,20 +1641,6 @@ async function updateChallenge(currentUser, challengeId, data) {
16411641
`Cannot update prizeSets for challenges with status: ${finalStatus}!`
16421642
);
16431643
}
1644-
const prizeSetsGroup = _.groupBy(data.prizeSets, "type");
1645-
if (
1646-
!prizeSetsGroup[constants.prizeSetTypes.ChallengePrizes] &&
1647-
_.get(challenge, "overview.totalPrizes")
1648-
) {
1649-
// remove the totalPrizes if challenge prizes are empty
1650-
data.overview = challenge.overview = _.omit(challenge.overview, ["totalPrizes"]);
1651-
} else {
1652-
const totalPrizes = helper.sumOfPrizes(
1653-
prizeSetsGroup[constants.prizeSetTypes.ChallengePrizes][0].prizes
1654-
);
1655-
_.assign(challenge, { overview: { totalPrizes } });
1656-
_.assign(data, { overview: { totalPrizes } });
1657-
}
16581644
}
16591645

16601646
let phasesUpdated = false;

0 commit comments

Comments
 (0)