Skip to content

Commit c59aa2d

Browse files
committed
fix: populate 'winners' array during payments
1 parent 4676fde commit c59aa2d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/services/PaymentService.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function createPayment (options) {
3939
const challengeId = await createChallenge(options, token)
4040
await addResourceToChallenge(challengeId, options.userHandle, token)
4141
await activateChallenge(challengeId, token)
42-
const completedChallenge = await closeChallenge(challengeId, token)
42+
const completedChallenge = await closeChallenge(challengeId, options.userHandle, token)
4343
return completedChallenge
4444
}
4545

@@ -146,14 +146,21 @@ async function activateChallenge (id, token) {
146146
/**
147147
* closes the topcoder challenge
148148
* @param {String} id the challenge id
149+
* @param {String} userHandle the user handle
149150
* @param {String} token m2m token
150151
* @returns {Object} the closed challenge
151152
*/
152-
async function closeChallenge (id, token) {
153+
async function closeChallenge (id, userHandle, token) {
153154
localLogger.info({ context: 'closeChallenge', message: `Closing challenge ${id}` })
154155
try {
156+
const [ { userId } ] = await helper.getMemberDetailsByHandles([ userHandle ])
155157
const body = {
156-
status: constants.ChallengeStatus.COMPLETED
158+
status: constants.ChallengeStatus.COMPLETED,
159+
winners: [{
160+
userId,
161+
handle: userHandle,
162+
placement: 1
163+
}]
157164
}
158165
const response = await helper.updateChallenge(id, body, token)
159166
localLogger.info({ context: 'closeChallenge', message: `Challenge ${id} is closed successfully.` })

0 commit comments

Comments
 (0)