Skip to content

AdHocFiltersRecommendations: Dedupe filters#1379

Merged
mdvictor merged 2 commits intomainfrom
mdv/dedupe-recent-filters
Mar 13, 2026
Merged

AdHocFiltersRecommendations: Dedupe filters#1379
mdvictor merged 2 commits intomainfrom
mdv/dedupe-recent-filters

Conversation

@mdvictor
Copy link
Copy Markdown
Collaborator

@mdvictor mdvictor commented Mar 4, 2026

There was a bug where adding mulitple times the same filter would then show that same filter duplicated in the recent filters area. This PR adds deduping so it only shows unique recent filters

For testing:

  • Enable drilldownRecommendations
  • try setting the same filter multiple times in the adhoc filters bar
  • check the recent filters popup and see that the values are not duplicated

Comment on lines +199 to +201
(f: AdHocFilterWithLabels) =>
!(f.key === filter.key && f.operator === filter.operator && f.value === filter.value)
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not a blocker so your call but this could be a bit improved by reusing deduplicateFilters({ ...allRecentFilters, filter })so we dont duplicate the comparison. It will take us from O(n) to O(n2) but switching from an Array to a Map would fix it as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

great catch! we have a hard limit on these keys of 10 so performance wouldn't be a big issue, but nonetheless you are right and optimizations are always good! I've moved the O(n^2) deduplication to a linear map. Thank you!

@mdvictor mdvictor merged commit 0454c0f into main Mar 13, 2026
12 checks passed
@mdvictor mdvictor deleted the mdv/dedupe-recent-filters branch March 13, 2026 14:04
@mdvictor mdvictor added patch Increment the patch version when merged release Create a release when this pr is merged labels Mar 13, 2026
@scenes-repo-bot-access-token
Copy link
Copy Markdown

🚀 PR was released in v7.1.7 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged release Create a release when this pr is merged released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants