Skip to content

Commit 7e1f3f1

Browse files
remove logging and fix issue with prizeSets
1 parent 67504e6 commit 7e1f3f1

File tree

1 file changed

+2
-56
lines changed

1 file changed

+2
-56
lines changed

src/services/ChallengeService.js

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,64 +1049,14 @@ function isDifferentPhases (phases = [], otherPhases) {
10491049
}
10501050
}
10511051

1052-
/**
1053-
* Check whether given two Prize Array are the same.
1054-
* @param {Array} prizes the first Prize Array
1055-
* @param {Array} otherPrizes the second Prize Array
1056-
* @returns {Boolean} true if the same, false otherwise
1057-
*/
1058-
function isSamePrizeArray (prizes, otherPrizes) {
1059-
const length = otherPrizes.length
1060-
if (prizes.length === otherPrizes.length) {
1061-
let used = Array(length).fill(false)
1062-
for (const prize of prizes) {
1063-
let index = -1
1064-
for (let i = 0; i < length; i++) {
1065-
if (!used[i] && prize.description === otherPrizes[i].description &&
1066-
prize.type === otherPrizes[i].type &&
1067-
prize.value === otherPrizes[i].value) {
1068-
used[i] = true
1069-
index = i
1070-
break
1071-
}
1072-
}
1073-
if (index === -1) {
1074-
return false
1075-
}
1076-
}
1077-
return true
1078-
} else {
1079-
return false
1080-
}
1081-
}
1082-
10831052
/**
10841053
* Check whether given two PrizeSet Array are different.
10851054
* @param {Array} prizeSets the first PrizeSet Array
10861055
* @param {Array} otherPrizeSets the second PrizeSet Array
10871056
* @returns {Boolean} true if different, false otherwise
10881057
*/
1089-
function isDifferentPrizeSets (prizeSets = [], otherPrizeSets) {
1090-
const length = otherPrizeSets.length
1091-
if (prizeSets.length === otherPrizeSets.length) {
1092-
let used = Array(length).fill(false)
1093-
for (const set of prizeSets) {
1094-
let index = -1
1095-
for (let i = 0; i < length; i++) {
1096-
if (!used[i] && set.type === otherPrizeSets[i].type &&
1097-
set.description === otherPrizeSets[i].description &&
1098-
isSamePrizeArray(set.prizes, otherPrizeSets[i].prizes)) {
1099-
used[i] = true
1100-
index = i
1101-
break
1102-
}
1103-
}
1104-
if (index === -1) {
1105-
return true
1106-
}
1107-
}
1108-
}
1109-
return false
1058+
function isDifferentPrizeSets (prizeSets = [], otherPrizeSets = []) {
1059+
return !_.isEqual(_.sortBy(prizeSets, 'type'), _.sortBy(otherPrizeSets, 'type'))
11101060
}
11111061

11121062
/**
@@ -1160,7 +1110,6 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
11601110
// helper.ensureNoDuplicateOrNullElements(data.gitRepoURLs, 'gitRepoURLs')
11611111

11621112
const challenge = await helper.getById('Challenge', challengeId)
1163-
logger.debug(`Dynamo Object before update: ${JSON.stringify(challenge)}`)
11641113
// FIXME: Tech Debt
11651114
let billingAccountId
11661115
if (data.status) {
@@ -1523,8 +1472,6 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
15231472
}
15241473

15251474
logger.debug(`Challenge.update id: ${challengeId} Details: ${JSON.stringify(updateDetails)}`)
1526-
logger.debug(`Dynamo Object before writing to dynamo: ${JSON.stringify(challenge)}`)
1527-
logger.debug(`Dynamo update operations: ${JSON.stringify(updateDetails)}`)
15281475
await models.Challenge.update({ id: challengeId }, updateDetails)
15291476

15301477
if (auditLogs.length > 0) {
@@ -1570,7 +1517,6 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
15701517
if (billingAccountId) {
15711518
busEventPayload.billingAccountId = billingAccountId
15721519
}
1573-
logger.debug(`ES Object before posting to bus: ${JSON.stringify(busEventPayload)}`)
15741520
await helper.postBusEvent(constants.Topics.ChallengeUpdated, busEventPayload)
15751521

15761522
if (challenge.phases && challenge.phases.length > 0) {

0 commit comments

Comments
 (0)