-
Notifications
You must be signed in to change notification settings - Fork 855
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
[BUG] Check for duplicate data source id before fetching the data sources in index pattern selector #6498
Merged
Conversation
This file contains 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
Signed-off-by: Lu Yu <nluyu@amazon.com>
zhongnansu
approved these changes
Apr 17, 2024
ruanyl
approved these changes
Apr 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with a minor comment
Comment on lines
+178
to
+183
if ( | ||
dataSourceReference && | ||
!this.state.dataSourceIdToTitle.has(dataSourceReference.id) && | ||
!dataSourceIdSet.has(dataSourceReference.id) | ||
) { | ||
dataSourceIdSet.add(dataSourceReference.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify the logic a bit like this, then we don't need to add an extra variable dataSourceIdSet
Suggested change
if ( | |
dataSourceReference && | |
!this.state.dataSourceIdToTitle.has(dataSourceReference.id) && | |
!dataSourceIdSet.has(dataSourceReference.id) | |
) { | |
dataSourceIdSet.add(dataSourceReference.id); | |
const dataSourcesToFetch = new Set<string>(); | |
savedObjects.map((indexPatternSavedObject: SimpleSavedObject<any>) => { | |
const dataSourceReference = getDataSourceReference(indexPatternSavedObject.references); | |
if (dataSourceReference && !this.state.dataSourceIdToTitle.has(dataSourceReference.id)) { | |
dataSourcesToFetch.add(dataSourceReference.id); | |
} | |
}); | |
const dataSourceIdToTitleToUpdate = new Map(); | |
if (dataSourcesToFetch.size > 0) { | |
const resp = await savedObjectsClient.bulkGet( | |
[...dataSourcesToFetch].map((id) => ({ type: 'data-source', id })) | |
); |
opensearch-trigger-bot bot
pushed a commit
that referenced
this pull request
Apr 17, 2024
…rces in index pattern selector (#6498) * remove duplicate entries Signed-off-by: Lu Yu <nluyu@amazon.com> * add test Signed-off-by: Lu Yu <nluyu@amazon.com> --------- Signed-off-by: Lu Yu <nluyu@amazon.com> (cherry picked from commit d2d410b) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
zhongnansu
pushed a commit
that referenced
this pull request
Apr 17, 2024
…rces in index pattern selector (#6498) (#6508) * remove duplicate entries * add test --------- (cherry picked from commit d2d410b) Signed-off-by: Lu Yu <nluyu@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
77 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
all-star-contributor
backport 2.x
multiple datasource
multiple datasource project
Skip-Changelog
PRs that are too trivial to warrant a changelog or release notes entry
v2.14.0
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.
Description
This change adds check for duplicate data source id before fetching the data sources in index pattern selector
Issues Resolved
Screenshot
duplicate.mp4
Testing the changes
The following steps were performed in the recording above:
Changelog
Check List
yarn test:jest
yarn test:jest_integration