LabelsFinder inherits from UnionFinder
This commit is contained in:
parent
476c26deb2
commit
cf14482a5a
|
@ -1,11 +1,11 @@
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue