Skip to content
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

fix: discord group search for multiple words in same string #897

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion __tests__/groups/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('Discord Groups Page', () => {
});

test('Should display only specified groups when name=<group-name> with different case', async () => {
const groupNames = 'fIrSt,DSA+COdInG';
const groupNames = 'fIrSt,COdInG';
yesyash marked this conversation as resolved.
Show resolved Hide resolved
await page.goto(`${PAGE_URL}/groups?name=${groupNames}`);
await page.waitForNetworkIdle();

Expand Down
8 changes: 7 additions & 1 deletion groups/utils.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • why is this change not under feature flag ?

Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,21 @@ function removeGroupKeywordFromDiscordRoleName(groupName) {

function getDiscordGroupIdsFromSearch(groups, multipleGroupSearch) {
if (!multipleGroupSearch) return groups.map((group) => group.id);

const GROUP_SEARCH_SEPARATOR = ',';
const searchGroups = multipleGroupSearch
.split(GROUP_SEARCH_SEPARATOR)
.map((group) => group.trim().toLowerCase());

const matchGroups = groups.filter((group) =>
searchGroups.some((searchGroup) =>
group.title.toLowerCase().startsWith(searchGroup),
group.title
.toLowerCase()
.split(' ')
.some((word) => word.startsWith(searchGroup)),
),
);

return matchGroups.map((group) => group.id);
}

Expand Down
Loading