LabelsFinder inherits from UnionFinder

parent 476c26de
class LabelsFinder
class LabelsFinder < UnionFinder
def initialize(current_user, params = {})
@current_user = current_user
@params = params
end
def execute
items = init_collection
items = find_union(label_ids, Label)
items = with_title(items)
sort(items)
end
......@@ -14,15 +14,10 @@ class LabelsFinder
attr_reader :current_user, :params
def init_collection
def label_ids
label_ids = []
label_ids << Label.where(group_id: projects.where.not(group: nil).select(:namespace_id)).select(:id)
label_ids << Label.where(project_id: projects).select(:id)
union = Gitlab::SQL::Union.new(label_ids)
Label.where("labels.id IN (#{union.to_sql})")
.reorder(title: :asc)
label_ids << Label.where(project_id: projects.select(:id)).select(:id)
end
def with_title(items)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment