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

Commit 7d762a8

Browse files
committed
moving the winners after cache lookup
1 parent 63b3892 commit 7d762a8

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/scripts/migrations/005-mmatches.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const migrationFunction = {
7272
updated: null, // pull from phase info
7373
updatedBy: 'applications',
7474
timelineTemplateId: null,
75-
phases: [], // TODO :: process phases
75+
phases: [],
7676
terms: [], // leave empty
7777
startDate: null, // pull from phase info
7878
numOfSubmissions: _.toNumber(c.numberOfSubmissions),
@@ -89,19 +89,6 @@ const migrationFunction = {
8989
newChallenge.created = challengeStartDate
9090
newChallenge.updated = challengeEndDate
9191

92-
const winners = _.map(c.winners, w => {
93-
return {
94-
handle: w.submitter
95-
// placement: w.rank // TODO :: missing placement?
96-
// TODO :: missing points as an object property
97-
}
98-
})
99-
newChallenge.winners = winners
100-
101-
// const savedChallenge = await challengeService.save(newChallenge)
102-
// logger.debug(`Challenge: ${JSON.stringify(newChallenge)}`)
103-
const savedChallenge = { id: uuid() }
104-
10592
let handlesToLookup = []
10693
for (const registrant of c.registrants) {
10794
// build cache
@@ -115,7 +102,18 @@ const migrationFunction = {
115102
}
116103
await cacheHandles(handlesToLookup)
117104

118-
logger.debug(`Final Cache: ${JSON.stringify(memberHandleCache)}`)
105+
const winners = _.map(c.winners, w => {
106+
return {
107+
handle: w.submitter
108+
// placement: w.rank // TODO :: missing placement?
109+
// TODO :: missing points as an object property
110+
}
111+
})
112+
newChallenge.winners = winners
113+
114+
// const savedChallenge = await challengeService.save(newChallenge)
115+
const savedChallenge = { id: uuid() }
116+
logger.debug(`Challenge: ${JSON.stringify(newChallenge)}`)
119117

120118
for (const registrant of c.registrants) {
121119
const memberId = await getMemberIdFromCache(registrant.handle)
@@ -131,7 +129,7 @@ const migrationFunction = {
131129
roleId: config.SUBMITTER_ROLE_ID
132130
}
133131
// await resourceService.save(newResource)
134-
logger.debug(`Resource: ${JSON.stringify(newResource)}`)
132+
// logger.debug(`Resource: ${JSON.stringify(newResource)}`)
135133
}
136134
return
137135
}
@@ -177,7 +175,7 @@ function convertPhases (v4PhasesArray) {
177175
const phases = _.map(v4PhasesArray, phase => {
178176
const start = moment(phase.actualStartTime)
179177
const end = moment(phase.actualEndTime)
180-
const v5duration = start.diff(end, 'seconds')
178+
const v5duration = end.diff(start, 'seconds')
181179
if (challengeStartDate === null) {
182180
challengeStartDate = moment(phase.actualStartTime).utc().format()
183181
}

0 commit comments

Comments
 (0)