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

Commit e68c46d

Browse files
committed
Fixing the created and createdBy being updated on update.
1 parent d3a1470 commit e68c46d

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/scripts/migrations/005-mmatches.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const migrationFunction = {
3030

3131
const challengeJson = { challenges: [] }
3232
const challengeIdsToDelete = []
33+
const missingIds = []
3334

3435
// logger.warn(await getMemberIdFromCache('TICKET_60375'))
3536
// return
@@ -40,12 +41,14 @@ const migrationFunction = {
4041
logger.info(`Found ${challenges.length} challenges`)
4142
if (challenges.length > 0) {
4243
for (const challenge of challenges) {
43-
logger.debug(`Loading challenge ${challenge.id}`)
44+
// logger.debug(`Loading challenge ${challenge.id}`)
4445
const c = await challengeService.getMMatchFromV4API(challenge.id)
4546
if (!c) {
4647
logger.warn(`Challenge Not Found in v4 API - ID: ${challenge.id}`)
48+
missingIds.push(challenge.id)
4749
continue
4850
}
51+
continue
4952

5053
const v5ChallengeLookup = await challengeService.getChallengeIDsFromV5({ legacyId: challenge.id }, 10)
5154
// logger.debug(JSON.stringify(v5ChallengeLookup))
@@ -195,6 +198,7 @@ const migrationFunction = {
195198
page++
196199
batch++
197200
}
201+
console.log('Missing IDs', missingIds)
198202
}
199203
}
200204

src/services/challengeService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ async function createChallenge (challenge) {
7272
*/
7373
async function updateChallenge (challenge) {
7474
try {
75+
const updateChallenge = new Challenge(_.omit(challenge, ['created', 'createdBy']))
7576
// numOfSubmissions and numOfRegistrants are not stored in dynamo, they're calclated by the ES processor
76-
await Challenge.update({ id: challenge.id }, _.omit(challenge, challengePropertiesToOmitFromDynamo))
77+
await Challenge.update({ id: challenge.id }, _.omit(updateChallenge, challengePropertiesToOmitFromDynamo))
7778
await getESClient().update({
7879
index: config.get('ES.CHALLENGE_ES_INDEX'),
7980
type: config.get('ES.CHALLENGE_ES_TYPE'),

src/services/syncService.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ async function processChallenge (legacyId, challengeListing, challengeDetails) {
4747
const v5ChallengeObjectFromV4 = await challengeService.buildV5Challenge(legacyId, challengeListing, challengeDetails)
4848
const [v5ChallengeFromAPI] = await challengeService.getChallengeFromV5API(legacyId)
4949

50-
logger.debug(`V5 Object Built from V4: ${JSON.stringify(v5ChallengeObjectFromV4)}`)
51-
logger.debug(`V5 Object from API: ${JSON.stringify(v5ChallengeFromAPI)}`)
50+
// logger.debug(`V5 Object Built from V4: ${JSON.stringify(v5ChallengeObjectFromV4)}`)
51+
// logger.debug(`V5 Object from API: ${JSON.stringify(v5ChallengeFromAPI)}`)
5252

5353
const additionalInformation = {}
5454

@@ -87,14 +87,23 @@ async function processChallenge (legacyId, challengeListing, challengeDetails) {
8787
ommittedFields.push('privateDescription')
8888
}
8989
const challengeV4Prizes = _.get(v5ChallengeObjectFromV4, 'prizeSets', [])
90-
logger.debug(`v4 prizes: ${JSON.stringify(challengeV4Prizes)}`)
90+
// logger.debug(`v4 prizes: ${JSON.stringify(challengeV4Prizes)}`)
9191
const challengeV5APIPrizes = _.get(v5ChallengeFromAPI, 'prizeSets', [])
92+
<<<<<<< Updated upstream
9293
logger.debug(`v5 prizes: ${JSON.stringify(challengeV5APIPrizes)}`)
9394
const prizeSets = _.filter([
9495
..._.intersectionBy(challengeV4Prizes, challengeV5APIPrizes, 'type'),
9596
..._.differenceBy(challengeV5APIPrizes, challengeV4Prizes, 'type')
9697
], entry => entry.type !== config.COPILOT_PAYMENT_TYPE)
9798
logger.debug(`intersection: ${JSON.stringify(prizeSets)}`)
99+
=======
100+
// logger.debug(`v5 prizes: ${JSON.stringify(challengeV5APIPrizes)}`)
101+
const prizeSets = [
102+
..._.intersectionBy(challengeV4Prizes, challengeV5APIPrizes, 'type'),
103+
..._.differenceBy(challengeV5APIPrizes, challengeV4Prizes, 'type')
104+
]
105+
// logger.debug(`intersection: ${JSON.stringify(prizeSets)}`)
106+
>>>>>>> Stashed changes
98107

99108
const copilotPayment = await challengeIfxService.getCopilotPaymentFromIfx(legacyId)
100109
if (copilotPayment) {
@@ -115,7 +124,7 @@ async function processChallenge (legacyId, challengeListing, challengeDetails) {
115124
prizeSets,
116125
...additionalInformation
117126
}
118-
logger.debug(`new V5 Object: ${JSON.stringify(updatedV5Object)}`)
127+
// logger.debug(`new V5 Object: ${JSON.stringify(updatedV5Object)}`)
119128
return challengeService.save(updatedV5Object)
120129
}
121130

0 commit comments

Comments
 (0)