@@ -140,7 +140,7 @@ async function addTopcoderRoles (allVanillaRoles, topcoderRoleNames) {
140
140
* @param {Object } challenge the challenge data
141
141
*/
142
142
async function createVanillaGroup ( challenge ) {
143
- logger . info ( `The challenge with challengeID =${ challenge . id } :` )
143
+ logger . info ( `Create: challengeID= ${ challenge . id } , status= ${ challenge . status } , selfService =${ challenge . legacy . selfService } :` )
144
144
const { text : challengeDetailsData , status : responseStatus } = await topcoderApi . getChallenge ( challenge . id )
145
145
const challengeDetails = JSON . parse ( challengeDetailsData )
146
146
@@ -163,6 +163,12 @@ async function createVanillaGroup (challenge) {
163
163
throw new Error ( 'Multiple discussions with type=\'challenge\' and provider=\'vanilla\' are not supported.' )
164
164
}
165
165
166
+ const isSelfService = challenge . legacy . selfService && challenge . legacy . selfService === true ? true : false
167
+ if ( isSelfService && challenge . status !== constants . TOPCODER . CHALLENGE_STATUSES . ACTIVE ) {
168
+ logger . info ( `The forums are created only for self-service challenges with the Active status.` )
169
+ return
170
+ }
171
+
166
172
const { body : project } = await topcoderApi . getProject ( challenge . projectId )
167
173
const allProjectRoles = _ . values ( constants . TOPCODER . PROJECT_ROLES )
168
174
const members = _ . filter ( project . members , member => {
@@ -199,7 +205,6 @@ async function createVanillaGroup (challenge) {
199
205
200
206
logger . info ( `Creating Vanilla entities for the '${ challengeDetailsDiscussion . name } ' discussion ....` )
201
207
202
- const isSelfService = challenge . legacy . selfService && challenge . legacy . selfService === true ? true : false
203
208
const groupNameTemplate = _ . template ( groupTemplate . group . name )
204
209
const groupDescriptionTemplate = challenge . legacy . selfService ? _ . template ( groupTemplate . group . selfServiceDescription )
205
210
: _ . template ( groupTemplate . group . description )
@@ -286,11 +291,18 @@ async function createVanillaGroup (challenge) {
286
291
* @param {Object } challenge the challenge data
287
292
*/
288
293
async function updateVanillaGroup ( challenge ) {
289
- logger . info ( `The challenge with challengeID =${ challenge . id } :` )
294
+ logger . info ( `Update: challengeID= ${ challenge . id } , status= ${ challenge . status } , selService =${ challenge . legacy . selfService } :` )
290
295
291
296
const { body : groups } = await vanillaClient . searchGroups ( challenge . id )
292
297
if ( groups . length === 0 ) {
293
- throw new Error ( 'The group wasn\'t found for this challenge' )
298
+ const isSelfService = challenge . legacy . selfService && challenge . legacy . selfService === true ? true : false
299
+ // Create the forums for self-service challenges with the Active status
300
+ if ( isSelfService && challenge . status === constants . TOPCODER . CHALLENGE_STATUSES . ACTIVE ) {
301
+ await createVanillaGroup ( challenge )
302
+ return
303
+ } else {
304
+ throw new Error ( 'The group wasn\'t found for this challenge' )
305
+ }
294
306
}
295
307
296
308
if ( groups . length > 1 ) {
0 commit comments