File tree 1 file changed +17
-14
lines changed
1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -69,10 +69,6 @@ async function searchChallenges (currentUser, criteria) {
69
69
boolQuery . push ( filter )
70
70
} )
71
71
72
- if ( criteria . memberId ) {
73
- const ids = await helper . listChallengesByMember ( criteria . memberId )
74
- boolQuery . push ( { terms : { _id : ids } } )
75
- }
76
72
if ( criteria . tag ) {
77
73
boolQuery . push ( { match_phrase : { tags : criteria . tag } } )
78
74
}
@@ -95,19 +91,26 @@ async function searchChallenges (currentUser, criteria) {
95
91
boolQuery . push ( { range : { updated : { lte : criteria . updatedDateEnd } } } )
96
92
}
97
93
98
- const shouldQuery = [ ]
94
+ const mustQuery = [ ]
95
+
96
+ const accessQuery = [ ]
99
97
100
98
if ( currentUser . handle ) {
101
- shouldQuery . push ( {
102
- bool : {
103
- filter : [
104
- { match_phrase : { createdBy : currentUser . handle } }
105
- ]
106
- }
107
- } )
99
+ accessQuery . push ( { match_phrase : { createdBy : currentUser . handle } } )
100
+ }
101
+
102
+ if ( criteria . memberId ) {
103
+ const ids = await helper . listChallengesByMember ( criteria . memberId )
104
+ accessQuery . push ( { terms : { _id : ids } } )
108
105
}
109
106
110
- shouldQuery . push ( {
107
+ mustQuery . push ( {
108
+ bool : {
109
+ should : accessQuery
110
+ }
111
+ } )
112
+
113
+ mustQuery . push ( {
111
114
bool : {
112
115
filter : boolQuery
113
116
}
@@ -121,7 +124,7 @@ async function searchChallenges (currentUser, criteria) {
121
124
body : {
122
125
query : {
123
126
bool : {
124
- should : shouldQuery
127
+ must : mustQuery
125
128
}
126
129
} ,
127
130
sort : [ { 'created' : { 'order' : 'asc' } } ]
You can’t perform that action at this time.
0 commit comments