Skip to content

use groups keyword to filter by groups #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ workflows:
only:
- dev
- PLAT-3614
- feat/group-search

- "build-qa":
context: org-global
Expand Down
8 changes: 2 additions & 6 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,12 @@ async function searchChallenges(currentUser, criteria) {
mustNotQuery.push({ exists: { field: "groups" } });
} else if (!currentUser.isMachine && !_hasAdminRole) {
// If the user is not M2M and is not an admin, return public + challenges from groups the user can access
_.each(accessibleGroups, (g) => {
groupsQuery.push({ match_phrase: { groups: g } });
});
groupsQuery.push({ terms: { "groups.keyword": accessibleGroups } });
// include public challenges
groupsQuery.push({ bool: { must_not: { exists: { field: "groups" } } } });
}
} else {
_.each(groupsToFilter, (g) => {
groupsQuery.push({ match_phrase: { groups: g } });
});
groupsQuery.push({ terms: { "groups.keyword": groupsToFilter } });
}

if (criteria.ids) {
Expand Down