@@ -204,7 +204,8 @@ async function createVanillaGroup (challenge) {
204204 type : groupTemplate . group . type ,
205205 description : groupDescriptionTemplate ( { challenge } ) ,
206206 challengeID : `${ challenge . id } ` ,
207- challengeUrl : `${ challenge . url } `
207+ challengeUrl : `${ challenge . url } ` ,
208+ archived : true
208209 } )
209210
210211 if ( ! group . groupID ) {
@@ -229,7 +230,8 @@ async function createVanillaGroup (challenge) {
229230 urlcode : `${ challenge . id } ` ,
230231 parentCategoryID : parentCategory [ 0 ] . categoryID ,
231232 displayAs : groupTemplate . categories ? constants . VANILLA . CATEGORY_DISPLAY_STYLE . CATEGORIES : constants . VANILLA . CATEGORY_DISPLAY_STYLE . DISCUSSIONS ,
232- groupID : group . groupID
233+ groupID : group . groupID ,
234+ archived : true
233235 } )
234236
235237 logger . info ( `The '${ challengeCategory . name } ' category was created` )
@@ -241,7 +243,8 @@ async function createVanillaGroup (challenge) {
241243 name : item . name ,
242244 urlcode : `${ urlCodeTemplate ( { challenge } ) } ` ,
243245 parentCategoryID : challengeCategory . categoryID ,
244- groupID : group . groupID
246+ groupID : group . groupID ,
247+ archived : true
245248 } )
246249 logger . info ( `The '${ item . name } ' category was created` )
247250 await createDiscussions ( group , challenge , item . discussions , childCategory )
@@ -286,8 +289,25 @@ async function updateVanillaGroup (challenge) {
286289 throw new Error ( 'Multiple groups were found for this challenge' )
287290 }
288291
292+ if ( challenge . status === constants . TOPCODER . CHALLENGE_STATUSES . ACTIVE ) {
293+ await vanillaClient . unarchiveGroup ( groups [ 0 ] . groupID )
294+ logger . info ( `The group with groupID=${ groups [ 0 ] . groupID } was unarchived.` )
295+ } else if ( _ . includes ( [ constants . TOPCODER . CHALLENGE_STATUSES . COMPLETED ,
296+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED ,
297+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_FAILED_REVIEW ,
298+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_FAILED_SCREENING ,
299+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_ZERO_SUBMISSIONS ,
300+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_WINNER_UNRESPONSIVE ,
301+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_CLIENT_REQUEST ,
302+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_REQUIREMENTS_INFEASIBLE ,
303+ constants . TOPCODER . CHALLENGE_STATUSES . CANCELLED_ZERO_REGISTRATIONS ,
304+ constants . TOPCODER . CHALLENGE_STATUSES . DELETED ] , challenge . status ) ) {
305+ await vanillaClient . archiveGroup ( groups [ 0 ] . groupID )
306+ logger . info ( `The group with groupID=${ groups [ 0 ] . groupID } was archived.` )
307+ }
308+
289309 const { body : updatedGroup } = await vanillaClient . updateGroup ( groups [ 0 ] . groupID , { name : challenge . name } )
290- logger . info ( `The group was updated: ${ JSON . stringify ( updatedGroup ) } ` )
310+ logger . info ( `The group with groupID= ${ groups [ 0 ] . groupID } was updated: ${ JSON . stringify ( updatedGroup ) } ` )
291311
292312 const { body : groupCategory } = await vanillaClient . getCategoryByUrlcode ( `${ challenge . id } ` )
293313 if ( ! groupCategory ) {
0 commit comments