Skip to content

Commit 4c93b66

Browse files
Fix groups query on challenges
1 parent 3be96fe commit 4c93b66

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/services/ChallengeService.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ async function searchChallenges (currentUser, criteria) {
121121
if (criteria.group && !_.isUndefined(currentUser)) {
122122
boolQuery.push({ match_phrase: { groups: criteria.group } })
123123
}
124-
if (criteria.groups && !_.isUndefined(currentUser)) {
125-
for (const group of criteria.groups) {
126-
boolQuery.push({ match: { groups: group } })
127-
}
128-
}
129124
if (criteria.gitRepoURL) {
130125
boolQuery.push({ match_phrase: { gitRepoURLs: criteria.gitRepoURL } })
131126
}
@@ -164,6 +159,22 @@ async function searchChallenges (currentUser, criteria) {
164159

165160
const mustQuery = []
166161

162+
const shouldQuery = []
163+
164+
if (criteria.groups && !_.isUndefined(currentUser)) {
165+
for (const group of criteria.groups) {
166+
shouldQuery.push({ match: { groups: group } })
167+
}
168+
}
169+
170+
if (shouldQuery.length > 0) {
171+
mustQuery.push({
172+
bool: {
173+
should: shouldQuery
174+
}
175+
})
176+
}
177+
167178
let mustNotQuery
168179

169180
const accessQuery = []

0 commit comments

Comments
 (0)