Enhance fetchEntities with search term permutations and deduplication#9101
Open
vedantlavale wants to merge 1 commit into
Open
Enhance fetchEntities with search term permutations and deduplication#9101vedantlavale wants to merge 1 commit into
vedantlavale wants to merge 1 commit into
Conversation
…mutations and deduplication Signed-off-by: vedantlavale <vedantlavale@gmail.com>
Contributor
Missing ChangesetsThe following package(s) are changed by this PR but do not have a changeset:
See CONTRIBUTING.md for more information about how to add changesets. Changed Packages
|
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the wheel-of-names participant lookup by enhancing EntityService.fetchEntities() to support 2-word search term permutations (e.g., “Jane Smith” vs “Smith Jane”) and deduplicate merged results, with accompanying unit tests.
Changes:
- Added permutation search for 2-word queries by issuing catalog queries for both word orders and merging results.
- Added client-side deduplication and sorting of merged entity results.
- Introduced unit tests covering permutation search, deduplication, and pagination behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
workspaces/wheel-of-names/plugins/wheel-of-names/src/components/Participants/Service.ts |
Adds 2-word permutation querying, merges/dedupes/sorts results, and applies client-side paging. |
workspaces/wheel-of-names/plugins/wheel-of-names/src/components/Participants/Service.test.ts |
Adds unit tests for the updated fetchEntities behavior and related regressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
32
to
36
| const queryOptions: QueryEntitiesRequest = { | ||
| filter: [{ kind: 'group' }, { kind: 'user' }], | ||
| limit: limit, | ||
| offset: offset, | ||
| limit: limit * 2, | ||
| offset: 0, | ||
| orderFields: { field: 'metadata.name', order: 'asc' }, |
Comment on lines
+81
to
+85
| const items = uniqueItems.slice(start, end); | ||
|
|
||
| const totalItems = uniqueItems.length; | ||
|
|
||
| return { items, totalItems }; |
Comment on lines
+69
to
+73
| const uniqueItems = allItems.filter( | ||
| (item, index, self) => | ||
| item.metadata.uid && | ||
| self.findIndex(i => i.metadata.uid === item.metadata.uid) === index, | ||
| ); |
Comment on lines
+48
to
68
| const allItems: Entity[] = []; | ||
|
|
||
| for (const term of terms) { | ||
| const options: QueryEntitiesRequest = { | ||
| ...queryOptions, | ||
| }; | ||
| if (term) { | ||
| options.fullTextFilter = { | ||
| term, | ||
| fields: [ | ||
| 'metadata.name', | ||
| 'kind', | ||
| 'spec.profile.displayName', | ||
| 'metadata.title', | ||
| ], | ||
| }; | ||
| } | ||
| const response = await this.catalogApi.queryEntities(options); | ||
| allItems.push(...response.items); | ||
| } | ||
|
|
Comment on lines
+46
to
+51
| expect(mockCatalogApi.queryEntities).toHaveBeenCalledWith({ | ||
| filter: [{ kind: 'group' }, { kind: 'user' }], | ||
| limit: 20, | ||
| offset: 0, | ||
| orderFields: { field: 'metadata.name', order: 'asc' }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix user search failing for reversed display name order
Issue Summary
The wheel-of-names participant search failed when user names were entered in a different order than the stored
displayName.For example:
displayName: "Jane Smith""Jane Smith"→ worked"Smith Jane"→ no resultsThis happened because the catalog API's
fullTextFilteruses substring matching, so reversed word order would not match the stored display name.Solution
Updated
EntityService.fetchEntities()to support name permutations for 2-word search queries.Changes made:
"first last""last first"This keeps the implementation backward compatible while improving search flexibility for users.
Testing
Added comprehensive unit tests in
Service.test.tscovering:Verified with mock user data including:
displayName: "Jane Smith"Files Changed
src/components/Participants/Service.tssrc/components/Participants/Service.test.tsScreenshots
Screenshots
Search using original name order
Search using reversed name order
Additional Notes
Signed-off-bylineSigned-off-bylineFixes #8472