@@ -57,7 +57,6 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
57
57
numberOfCheckpointsPrizes : challenge . numberOfCheckpointsPrizes ,
58
58
topCheckPointPrize : challenge . topCheckPointPrize ,
59
59
submissionsViewable : challenge . submissionsViewable || 'false' ,
60
- reviewType : challenge . reviewType ,
61
60
allowStockArt : challenge . allowStockArt === 'true' ,
62
61
fileTypes : challenge . filetypes || [ ] ,
63
62
environment : challenge . environment ,
@@ -66,12 +65,7 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
66
65
submissionLimit : Number ( challenge . submissionLimit ) || 0 ,
67
66
drPoints : challenge . digitalRunPoints ,
68
67
directUrl : challenge . directUrl ,
69
- tags : _ . union (
70
- challenge . technologies || [ ] ,
71
- challenge . technology || [ ] ,
72
- challenge . platforms || [ ] ,
73
- challenge . tags || [ ] ,
74
- ) ,
68
+ tags : challenge . tags || [ ] ,
75
69
prizes : challenge . prize || challenge . prizes || [ ] ,
76
70
events : _ . map ( challenge . event , e => ( {
77
71
eventName : e . eventShortDesc ,
@@ -80,7 +74,6 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
80
74
} ) ) ,
81
75
terms : challenge . terms ,
82
76
submissions : challenge . submissions ,
83
- track : _ . toUpper ( challenge . challengeCommunity ) ,
84
77
subTrack : challenge . subTrack ,
85
78
checkpoints : challenge . checkpoints ,
86
79
documents : challenge . documents || [ ] ,
@@ -147,7 +140,7 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
147
140
// Fill some derived data
148
141
const registrationOpen = _ . some (
149
142
allPhases ,
150
- phase => phase . name === 'Registration' && phase . isActive ,
143
+ phase => phase . name === 'Registration' && phase . isOpen ,
151
144
) ? 'Yes' : 'No' ;
152
145
_ . defaults ( finalChallenge , {
153
146
communities : new Set ( [ COMPETITION_TRACKS [ finalChallenge . track ] ] ) ,
@@ -180,7 +173,7 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
180
173
* @param {String } username Optional.
181
174
*/
182
175
export function normalizeChallenge ( challenge , username ) {
183
- const registrationOpen = ( challenge . allPhases || challenge . phases || [ ] ) . filter ( d => ( d . name === 'Registration' || ! d . name ) ) [ 0 ] . isActive ? 'Yes' : 'No' ;
176
+ const registrationOpen = ( challenge . allPhases || challenge . phases || [ ] ) . filter ( d => ( d . name === 'Registration' || ! d . name ) ) [ 0 ] . isOpen ? 'Yes' : 'No' ;
184
177
const groups = { } ;
185
178
if ( challenge . groupIds ) {
186
179
challenge . groupIds . forEach ( ( id ) => {
@@ -192,8 +185,7 @@ export function normalizeChallenge(challenge, username) {
192
185
if ( ! challenge . totalPrize ) {
193
186
challenge . totalPrize = challenge . prizes . reduce ( ( sum , x ) => sum + x , 0 ) ;
194
187
}
195
- if ( ! challenge . technologies ) challenge . technologies = [ ] ;
196
- if ( ! challenge . platforms ) challenge . platforms = [ ] ;
188
+ if ( ! challenge . tags ) challenge . tags = [ ] ;
197
189
198
190
if ( challenge . subTrack === 'DEVELOP_MARATHON_MATCH' ) {
199
191
challenge . track = 'DATA_SCIENCE' ;
@@ -339,7 +331,12 @@ class ChallengesService {
339
331
* is rejected.
340
332
*/
341
333
async activate ( challengeId ) {
342
- let res = await this . private . api . post ( `/challenges/${ challengeId } /activate` ) ;
334
+ const params = {
335
+ status : 'Active' ,
336
+ } ;
337
+
338
+ let res = await this . private . apiV5 . patch ( `/challenge/${ challengeId } ` , params ) ;
339
+
343
340
if ( ! res . ok ) throw new Error ( res . statusText ) ;
344
341
res = ( await res . json ( ) ) . result ;
345
342
if ( res . status !== 200 ) throw new Error ( res . content ) ;
@@ -349,15 +346,14 @@ class ChallengesService {
349
346
/**
350
347
* Closes the specified challenge.
351
348
* @param {Number } challengeId
352
- * @param {Number } winnerId Optional. ID of the assignee to declare the
353
- * winner.
354
349
* @return {Promise } Resolves to null value in case of success; otherwise it
355
350
* is rejected.
356
351
*/
357
- async close ( challengeId , winnerId ) {
358
- let url = `/challenges/${ challengeId } /close` ;
359
- if ( winnerId ) url = `${ url } ?winnerId=${ winnerId } ` ;
360
- let res = await this . private . api . post ( url ) ;
352
+ async close ( challengeId ) {
353
+ const params = {
354
+ status : 'Completed' ,
355
+ } ;
356
+ let res = await this . private . apiV5 . patch ( `/challenges/${ challengeId } /close` , params ) ;
361
357
if ( ! res . ok ) throw new Error ( res . statusText ) ;
362
358
res = ( await res . json ( ) ) . result ;
363
359
if ( res . status !== 200 ) throw new Error ( res . content ) ;
@@ -375,7 +371,7 @@ class ChallengesService {
375
371
* @param {String } submissionGuidelines
376
372
* @param {Number } copilotId
377
373
* @param {Number } copilotFee
378
- * @param {? } technologies
374
+ * @param {? } tags
379
375
* @return {Promise } Resolves to the created challenge object (payment task).
380
376
*/
381
377
async createTask (
@@ -388,7 +384,7 @@ class ChallengesService {
388
384
submissionGuidelines ,
389
385
copilotId ,
390
386
copilotFee ,
391
- technologies ,
387
+ tags ,
392
388
) {
393
389
const payload = {
394
390
param : {
@@ -399,7 +395,7 @@ class ChallengesService {
399
395
submissionGuidelines,
400
396
milestoneId : 1 ,
401
397
name : title ,
402
- technologies ,
398
+ tags ,
403
399
prizes : payment ? [ payment ] : [ ] ,
404
400
projectId,
405
401
registrationStartsAt : moment ( ) . toISOString ( ) ,
@@ -467,11 +463,11 @@ class ChallengesService {
467
463
}
468
464
469
465
/**
470
- * Gets possible challenge subtracks .
466
+ * Gets possible challenge types .
471
467
* @return {Promise } Resolves to the array of subtrack names.
472
468
*/
473
- getChallengeSubtracks ( ) {
474
- return this . private . apiV5 . get ( '/challengetypes ' )
469
+ getChallengeTypes ( ) {
470
+ return this . private . apiV5 . get ( '/challenge-types ' )
475
471
. then ( res => ( res . ok ? res . json ( ) : new Error ( res . statusText ) ) )
476
472
. then ( res => (
477
473
res . message
@@ -511,18 +507,15 @@ class ChallengesService {
511
507
/**
512
508
* Gets SRM matches.
513
509
* @param {Object } params
510
+ * @param {string } typeId Challenge SRM TypeId
514
511
* @return {Promise }
515
512
*/
516
513
async getSrms ( params ) {
517
- const res = await this . private . api . get ( `/srms /?${ qs . stringify ( params ) } ` ) ;
514
+ const res = await this . private . apiV5 . get ( `/challenges /?${ qs . stringify ( params ) } ` ) ;
518
515
return getApiResponsePayload ( res ) ;
519
516
}
520
517
521
518
static updateFiltersParamsForGettingMemberChallenges ( filters , params ) {
522
- if ( filters && filters . status === 'Active' ) {
523
- // eslint-disable-next-line no-param-reassign
524
- filters . status = 'ACTIVE' ;
525
- }
526
519
if ( params && params . perPage ) {
527
520
// eslint-disable-next-line no-param-reassign
528
521
params . offset = ( params . page - 1 ) * params . perPage ;
@@ -577,23 +570,31 @@ class ChallengesService {
577
570
/**
578
571
* Registers user to the specified challenge.
579
572
* @param {String } challengeId
573
+ * @param {String } memberHandle
574
+ * @param {String } roleId
580
575
* @return {Promise }
581
576
*/
582
- async register ( challengeId ) {
583
- const endpoint = `/challenges/${ challengeId } /register` ;
584
- const res = await this . private . api . postJson ( endpoint ) ;
577
+ async register ( challengeId , memberHandle , roleId ) {
578
+ const params = {
579
+ challengeId, memberHandle, roleId,
580
+ } ;
581
+ const res = await this . private . apiV5 . post ( '/resources' , params ) ;
585
582
if ( ! res . ok ) throw new Error ( res . statusText ) ;
586
583
return res . json ( ) ;
587
584
}
588
585
589
586
/**
590
587
* Unregisters user from the specified challenge.
591
588
* @param {String } challengeId
589
+ * @param {String } memberHandle
590
+ * @param {String } roleId
592
591
* @return {Promise }
593
592
*/
594
- async unregister ( challengeId ) {
595
- const endpoint = `/challenges/${ challengeId } /unregister` ;
596
- const res = await this . private . api . post ( endpoint ) ;
593
+ async unregister ( challengeId , memberHandle , roleId ) {
594
+ const params = {
595
+ challengeId, memberHandle, roleId,
596
+ } ;
597
+ const res = await this . private . apiV5 . post ( '/resources' , params ) ;
597
598
if ( ! res . ok ) throw new Error ( res . statusText ) ;
598
599
return res . json ( ) ;
599
600
}
0 commit comments