Skip to content

Commit b3bcc93

Browse files
committed
update overview
1 parent 1457dd7 commit b3bcc93

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
@@ -1298,7 +1298,6 @@ async function getChallenge(currentUser, id, checkIfExists) {
12981298
if (challenge.status !== constants.challengeStatuses.Completed) {
12991299
_.unset(challenge, "winners");
13001300
}
1301-
convertPrizeSetValuesToDollars(challenge.prizeSets, challenge.overview);
13021301

13031302
return challenge;
13041303
}
@@ -1425,6 +1424,7 @@ async function validateWinners(winners, challengeId) {
14251424
*/
14261425
async function updateChallenge(currentUser, challengeId, data) {
14271426
const challenge = await challengeDomain.lookup(getLookupCriteria("id", challengeId));
1427+
convertPrizeSetValuesToDollars(challenge.prizeSets, challenge.overview);
14281428

14291429
const projectId = _.get(challenge, "projectId");
14301430

@@ -1651,20 +1651,6 @@ async function updateChallenge(currentUser, challengeId, data) {
16511651
`Cannot update prizeSets for challenges with status: ${finalStatus}!`
16521652
);
16531653
}
1654-
const prizeSetsGroup = _.groupBy(data.prizeSets, "type");
1655-
if (
1656-
!prizeSetsGroup[constants.prizeSetTypes.ChallengePrizes] &&
1657-
_.get(challenge, "overview.totalPrizes")
1658-
) {
1659-
// remove the totalPrizes if challenge prizes are empty
1660-
data.overview = challenge.overview = _.omit(challenge.overview, ["totalPrizes"]);
1661-
} else {
1662-
const totalPrizes = helper.sumOfPrizes(
1663-
prizeSetsGroup[constants.prizeSetTypes.ChallengePrizes][0].prizes
1664-
);
1665-
_.assign(challenge, { overview: { totalPrizes } });
1666-
_.assign(data, { overview: { totalPrizes } });
1667-
}
16681654
}
16691655

16701656
let phasesUpdated = false;

0 commit comments

Comments
 (0)