@@ -39,7 +39,7 @@ async function createPayment (options) {
39
39
const challengeId = await createChallenge ( options , token )
40
40
await addResourceToChallenge ( challengeId , options . userHandle , token )
41
41
await activateChallenge ( challengeId , token )
42
- const completedChallenge = await closeChallenge ( challengeId , token )
42
+ const completedChallenge = await closeChallenge ( challengeId , options . userHandle , token )
43
43
return completedChallenge
44
44
}
45
45
@@ -146,14 +146,21 @@ async function activateChallenge (id, token) {
146
146
/**
147
147
* closes the topcoder challenge
148
148
* @param {String } id the challenge id
149
+ * @param {String } userHandle the user handle
149
150
* @param {String } token m2m token
150
151
* @returns {Object } the closed challenge
151
152
*/
152
- async function closeChallenge ( id , token ) {
153
+ async function closeChallenge ( id , userHandle , token ) {
153
154
localLogger . info ( { context : 'closeChallenge' , message : `Closing challenge ${ id } ` } )
154
155
try {
156
+ const { userId } = await helper . getV3MemberDetailsByHandle ( userHandle )
155
157
const body = {
156
- status : constants . ChallengeStatus . COMPLETED
158
+ status : constants . ChallengeStatus . COMPLETED ,
159
+ winners : [ {
160
+ userId,
161
+ handle : userHandle ,
162
+ placement : 1
163
+ } ]
157
164
}
158
165
const response = await helper . updateChallenge ( id , body , token )
159
166
localLogger . info ( { context : 'closeChallenge' , message : `Challenge ${ id } is closed successfully.` } )
0 commit comments