@@ -15,8 +15,6 @@ import { getApi } from './api';
15
15
import { getService as getMembersService } from './members' ;
16
16
import { getService as getSubmissionsService } from './submissions' ;
17
17
18
- const MAX_PER_PAGE = 300 ;
19
-
20
18
export function getFilterUrl ( backendFilter , frontFilter ) {
21
19
const ff = _ . clone ( frontFilter ) ;
22
20
// eslint-disable-next-line object-curly-newline
@@ -543,27 +541,16 @@ class ChallengesService {
543
541
544
542
const query = getFilterUrl ( filter . backendFilter , filter . frontFilter ) ;
545
543
546
- const totalQuery = getFilterUrl (
547
- filter . backendFilter ,
548
- { ...filter . frontFilter , page : 1 , perPage : MAX_PER_PAGE } ,
549
- ) ;
550
-
551
544
let res = { } ;
552
- let totalChallengeCount = { } ;
545
+ let totalCount = 0 ;
553
546
if ( _ . some ( filter . frontFilter . tracks , val => val )
554
547
&& ! _ . isEqual ( filter . frontFilter . types , [ ] ) ) {
555
548
const url = `/recommender-api/${ handle } ?${ query } ` ;
556
549
res = await this . private . apiV5 . get ( url ) . then ( checkErrorV5 ) ;
557
- // Note: Recommender API is not returning X-Total response header.
558
- // Please remove below statement with response get method.
559
- const totalUrl = `/recommender-api/${ handle } ?${ totalQuery } ` ;
560
- totalChallengeCount = await this . private . apiV5 . get ( totalUrl ) . then ( checkErrorV5 ) ;
550
+ totalCount = res . headers . get ( 'x-total' ) || 0 ;
561
551
}
562
- const challenges = res . result ? res . result . filter ( ch => ch . jaccard_index > 0 ) : [ ] ;
563
- const total = totalChallengeCount . result
564
- ? totalChallengeCount . result . filter ( ch => ch . jaccard_index > 0 ) : [ ] ;
565
552
566
- const totalCount = total . length ;
553
+ const challenges = res . result ? res . result . filter ( ch => ch . jaccard_index > 0 ) : [ ] ;
567
554
return {
568
555
challenges,
569
556
totalCount,
0 commit comments