diff --git a/app/components/filters_component.rb b/app/components/filters_component.rb index 12ec01fbb0d0..c35e9a3c5a2f 100644 --- a/app/components/filters_component.rb +++ b/app/components/filters_component.rb @@ -58,11 +58,7 @@ def allowed_filters end def filters_count - @filters_count ||= query - .filters - .map(&:class) - .uniq - .count + @filters_count ||= query.filters.count end protected diff --git a/app/models/queries/base_query.rb b/app/models/queries/base_query.rb index e7c5b6bbc500..848ac1323d37 100644 --- a/app/models/queries/base_query.rb +++ b/app/models/queries/base_query.rb @@ -88,11 +88,17 @@ def where(attribute, operator, values) filter.values = values filter.context = context + # Remove any previous instances of the same filter + remove_filter(filter.name) filters << filter self end + def remove_filter(name) + filters.delete(find_active_filter(name)) + end + def select(*select_values, add_not_existing: true) select_values.each do |select_value| select_column = select_for(select_value)