BigW Consortium Gitlab

LabelsFinder inherits from UnionFinder

parent 476c26de
class LabelsFinder class LabelsFinder < UnionFinder
def initialize(current_user, params = {}) def initialize(current_user, params = {})
@current_user = current_user @current_user = current_user
@params = params @params = params
end end
def execute def execute
items = init_collection items = find_union(label_ids, Label)
items = with_title(items) items = with_title(items)
sort(items) sort(items)
end end
...@@ -14,15 +14,10 @@ class LabelsFinder ...@@ -14,15 +14,10 @@ class LabelsFinder
attr_reader :current_user, :params attr_reader :current_user, :params
def init_collection def label_ids
label_ids = [] label_ids = []
label_ids << Label.where(group_id: projects.where.not(group: nil).select(:namespace_id)).select(:id) 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) label_ids << Label.where(project_id: projects.select(:id)).select(:id)
union = Gitlab::SQL::Union.new(label_ids)
Label.where("labels.id IN (#{union.to_sql})")
.reorder(title: :asc)
end end
def with_title(items) 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