Class: Issuables::LabelFilter

Inherits:
BaseFilter show all
Extended by:
Gitlab::Cache::RequestCache
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/finders/issuables/label_filter.rb

Constant Summary

Constants inherited from BaseFilter

BaseFilter::FILTER_ANY, BaseFilter::FILTER_NONE

Instance Attribute Summary

Attributes included from Gitlab::Cache::RequestCache

#request_cache_key_block

Instance Method Summary collapse

Methods included from Gitlab::Cache::RequestCache

extended, request_cache, request_cache_key

Methods inherited from BaseFilter

#initialize

Constructor Details

This class inherits a constructor from Issuables::BaseFilter

Instance Method Details

#filter(issuables) ⇒ Object



8
9
10
11
12
# File 'app/finders/issuables/label_filter.rb', line 8

def filter(issuables)
  filtered = by_label(issuables)
  filtered = by_label_union(filtered)
  by_negated_label(filtered)
end

rubocop: disable CodeReuse/ActiveRecord



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/finders/issuables/label_filter.rb', line 19

def label_link_query(issuables, label_ids: nil, label_names: nil)
  target_model = issuables.klass
  base_target_model = issuables.base_class

  # passing the original target_model just to avoid running the labels union query on group level issues pages
  # as the query becomes more expensive at group level. This is to be removed altogether as we migrate labels off
  # Epic altogether, planned as a high priority follow-up for Epic to WorkItem migration:
  # re https://gitlab.com/gitlab-org/gitlab/-/issues/465725
  relation = target_label_links_query(target_model, base_target_model, label_ids)
  relation = relation.joins(:label).where(labels: { name: label_names }) if label_names

  relation
end

#label_names_excluded_from_priority_sortObject



14
15
16
# File 'app/finders/issuables/label_filter.rb', line 14

def label_names_excluded_from_priority_sort
  label_names_from_params
end