Filter User Groups to Show Only Team Groups #391
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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