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

Filter User Groups to Show Only Team Groups #391

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

ssb-jnk
Copy link
Contributor

@ssb-jnk ssb-jnk commented Dec 17, 2024

This PR introduces changes to the utility function getTeamFromGroup to map a group name to the correct team name based on substring matching. The function ensures that the longest matching substring (team name) is selected when multiple matches are possible. Below is the detailed explanation, along with a test case to demonstrate the functionality.

Explanation:
The purpose of this function is to determine the team name for a given group name.

Key Assumptions:
A team name (stored in uniform_name) is always a substring of the corresponding group name.
If multiple team names match a group name (e.g., both donald-du and donald-duck match donald-duck-data-admins), the function selects the longest match because it represents the most accurate and specific team name.

How It Works:
Filter: Identify all team names where uniform_name is included in the groupName.
Sort: Sort the matching team names by their length in descending order.
Select: Return the longest match or an empty string if no matches are found.

Example:
For the group name donald-duck-data-admins:

Teams: ['donald-du', 'donald-duck', 'mickey-mouse']
Matches: ['donald-du', 'donald-duck']
Result: donald-duck (as it is the longest match).

I have added tests for getTeamFromGroup.

This change is Reviewable

@ssb-jnk ssb-jnk requested a review from a team as a code owner December 17, 2024 14:59
@ssb-jnk ssb-jnk changed the title Only show supported groups, managers, developers and data-admins Filter User Groups to Show Only Team Groups Dec 18, 2024
Copy link
Contributor

@skykanin skykanin left a comment

Choose a reason for hiding this comment

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

Very nice, and now with tests too!

Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ssb-jnk)

@ssb-jnk ssb-jnk merged commit 17a7ea2 into develop Dec 18, 2024
5 checks passed
@ssb-jnk ssb-jnk deleted the display-only-supported-groups branch December 18, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants