@@ -153,12 +153,6 @@ async function searchChallenges(currentUser, criteria) {
153
153
154
154
const _hasAdminRole = hasAdminRole ( currentUser ) ;
155
155
156
- const includeSelfService =
157
- currentUser &&
158
- ( currentUser . isMachine ||
159
- _hasAdminRole ||
160
- _ . includes ( config . SELF_SERVICE_WHITELIST_HANDLES , currentUser . handle . toLowerCase ( ) ) ) ;
161
-
162
156
const includedTrackIds = _ . isArray ( criteria . trackIds ) ? criteria . trackIds : [ ] ;
163
157
const includedTypeIds = _ . isArray ( criteria . typeIds ) ? criteria . typeIds : [ ] ;
164
158
@@ -463,6 +457,7 @@ async function searchChallenges(currentUser, criteria) {
463
457
}
464
458
465
459
let sortByProp = criteria . sortBy ? criteria . sortBy : "created" ;
460
+
466
461
const sortOrderProp = criteria . sortOrder ? criteria . sortOrder : "desc" ;
467
462
468
463
const mustQuery = [ ] ;
@@ -647,83 +642,6 @@ async function searchChallenges(currentUser, criteria) {
647
642
} ) ;
648
643
}
649
644
650
- if ( ! includeSelfService ) {
651
- mustQuery . push ( {
652
- bool : {
653
- should : [
654
- { bool : { must_not : { exists : { field : "legacy.selfService" } } } } ,
655
- ...( currentUser
656
- ? [
657
- {
658
- bool : {
659
- must : [
660
- {
661
- bool : {
662
- must_not : {
663
- match_phrase : {
664
- status : constants . challengeStatuses . New ,
665
- } ,
666
- } ,
667
- } ,
668
- } ,
669
- {
670
- bool : {
671
- must_not : {
672
- match_phrase : {
673
- status : constants . challengeStatuses . Draft ,
674
- } ,
675
- } ,
676
- } ,
677
- } ,
678
- {
679
- bool : {
680
- must_not : {
681
- match_phrase : {
682
- status : constants . challengeStatuses . Approved ,
683
- } ,
684
- } ,
685
- } ,
686
- } ,
687
- ] ,
688
- } ,
689
- } ,
690
- {
691
- bool : {
692
- must : { match_phrase : { createdBy : currentUser . handle } } ,
693
- } ,
694
- } ,
695
- ]
696
- : [
697
- {
698
- bool : {
699
- should : [
700
- {
701
- bool : {
702
- must : {
703
- match_phrase : {
704
- status : constants . challengeStatuses . Active ,
705
- } ,
706
- } ,
707
- } ,
708
- } ,
709
- {
710
- bool : {
711
- must : {
712
- match_phrase : {
713
- status : constants . challengeStatuses . Completed ,
714
- } ,
715
- } ,
716
- } ,
717
- } ,
718
- ] ,
719
- } ,
720
- } ,
721
- ] ) ,
722
- ] ,
723
- } ,
724
- } ) ;
725
- }
726
-
727
645
if ( groupsQuery . length > 0 ) {
728
646
mustQuery . push ( {
729
647
bool : {
@@ -781,12 +699,14 @@ async function searchChallenges(currentUser, criteria) {
781
699
[ sortByProp ] : {
782
700
order : sortOrderProp ,
783
701
missing : "_last" ,
784
- unmapped_type : "String " ,
702
+ unmapped_type : "keyword " ,
785
703
} ,
786
704
} ,
787
705
] ,
788
706
} ,
789
707
} ;
708
+
709
+ logger . info ( `ES Query: ${ JSON . stringify ( esQuery ) } ` )
790
710
// Search with constructed query
791
711
let docs ;
792
712
try {
@@ -795,6 +715,7 @@ async function searchChallenges(currentUser, criteria) {
795
715
? await esClient . search ( esQuery )
796
716
: ( await esClient . search ( esQuery ) ) . body ;
797
717
} catch ( e ) {
718
+ logger . error ( JSON . stringify ( e ) ) ;
798
719
// Catch error when the ES is fresh and has no data
799
720
docs = {
800
721
hits : {
0 commit comments