@@ -1049,64 +1049,14 @@ function isDifferentPhases (phases = [], otherPhases) {
1049
1049
}
1050
1050
}
1051
1051
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
-
1083
1052
/**
1084
1053
* Check whether given two PrizeSet Array are different.
1085
1054
* @param {Array } prizeSets the first PrizeSet Array
1086
1055
* @param {Array } otherPrizeSets the second PrizeSet Array
1087
1056
* @returns {Boolean } true if different, false otherwise
1088
1057
*/
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' ) )
1110
1060
}
1111
1061
1112
1062
/**
@@ -1160,7 +1110,6 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
1160
1110
// helper.ensureNoDuplicateOrNullElements(data.gitRepoURLs, 'gitRepoURLs')
1161
1111
1162
1112
const challenge = await helper . getById ( 'Challenge' , challengeId )
1163
- logger . debug ( `Dynamo Object before update: ${ JSON . stringify ( challenge ) } ` )
1164
1113
// FIXME: Tech Debt
1165
1114
let billingAccountId
1166
1115
if ( data . status ) {
@@ -1523,8 +1472,6 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
1523
1472
}
1524
1473
1525
1474
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 ) } ` )
1528
1475
await models . Challenge . update ( { id : challengeId } , updateDetails )
1529
1476
1530
1477
if ( auditLogs . length > 0 ) {
@@ -1570,7 +1517,6 @@ async function update (currentUser, challengeId, data, userToken, isFull) {
1570
1517
if ( billingAccountId ) {
1571
1518
busEventPayload . billingAccountId = billingAccountId
1572
1519
}
1573
- logger . debug ( `ES Object before posting to bus: ${ JSON . stringify ( busEventPayload ) } ` )
1574
1520
await helper . postBusEvent ( constants . Topics . ChallengeUpdated , busEventPayload )
1575
1521
1576
1522
if ( challenge . phases && challenge . phases . length > 0 ) {
0 commit comments