@@ -492,30 +492,22 @@ class ChallengesService {
492
492
async getUserChallenges ( userId , filters , params ) {
493
493
const userFilters = _ . cloneDeep ( filters ) ;
494
494
ChallengesService . updateFiltersParamsForGettingMemberChallenges ( userFilters , params ) ;
495
+ const query = {
496
+ ...params ,
497
+ ...userFilters ,
498
+ memberId : userId ,
499
+ } ;
500
+ const url = `/challenges?${ qs . stringify ( _ . omit ( query , [ 'limit' , 'offset' , 'technologies' ] ) ) } ` ;
501
+ const userChallenges = await this . private . apiV5 . get ( url )
502
+ . then ( checkErrorV5 )
503
+ . then ( ( res ) => {
504
+ res . result . forEach ( item => normalizeChallenge ( item , userId ) ) ;
505
+ return res . result ;
506
+ } ) ;
495
507
496
- const userChallenges = await this . private . apiV5 . get ( `/resources/${ userId } /challenges` )
497
- . then ( checkErrorV5 ) . then ( res => res ) ;
498
-
499
- let chResponse = null ;
500
- if ( userChallenges . result && userChallenges . result . length > 0 ) {
501
- const query = {
502
- ...params ,
503
- ...userFilters ,
504
- ids : userChallenges . result ,
505
- } ;
506
- const endpoint = '/challenges' ;
507
- const url = `${ endpoint } ?${ qs . stringify ( _ . omit ( query , [ 'limit' , 'offset' , 'technologies' ] ) ) } ` ;
508
- chResponse = await this . private . apiV5 . get ( url )
509
- . then ( checkErrorV5 ) . then ( ( res ) => {
510
- res . result . forEach ( item => normalizeChallenge ( item , userId ) ) ;
511
- return res ;
512
- } ) ;
513
- }
514
-
515
- const chResult = ( chResponse && chResponse . result ) || [ ] ;
516
508
return {
517
- challenges : chResult ,
518
- totalCount : chResult . length ,
509
+ challenges : userChallenges ,
510
+ totalCount : userChallenges . length ,
519
511
} ;
520
512
}
521
513
0 commit comments