Commit 8c16cd19 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'extract-ee-specific-lines-from-issuable-finders' into 'master'

Extract EE-specific lines from issuable finders

Closes #6631

See merge request gitlab-org/gitlab-ee!6701
parents f68011c2 d1ece3f8
......@@ -128,13 +128,7 @@ class IssuesFinder < IssuableFinder
end
def by_assignee(items)
if assignees.any?
assignees.each do |assignee|
items = items.assigned_to(assignee)
end
items
elsif assignee && assignees.empty?
if assignee
items.assigned_to(assignee)
elsif no_assignee?
items.unassigned
......@@ -144,17 +138,4 @@ class IssuesFinder < IssuableFinder
items
end
end
def assignees
return @assignees if defined?(@assignees)
@assignees =
if params[:assignee_ids]
User.where(id: params[:assignee_ids])
elsif params[:assignee_username]
User.where(username: params[:assignee_username])
else
[]
end
end
end
......@@ -37,18 +37,6 @@ class MergeRequestsFinder < IssuableFinder
private
def by_assignee(items)
if assignee
items = items.where(assignee_id: assignee.id)
elsif no_assignee?
items = items.where(assignee_id: nil)
elsif assignee_id? || assignee_username? # assignee not found
items = items.none
end
items
end
def source_branch
@source_branch ||= params[:source_branch].presence
end
......
......@@ -2,6 +2,7 @@ module EE
module IssuesFinder
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
include ::Gitlab::Utils::StrongMemoize
module ClassMethods
extend ::Gitlab::Utils::Override
......@@ -42,5 +43,30 @@ module EE
def filter_by_any_weight?
params[:weight] == ::Issue::WEIGHT_ANY
end
override :by_assignee
def by_assignee(items)
if assignees.any?
assignees.each do |assignee|
items = items.assigned_to(assignee)
end
return items
end
super
end
def assignees
strong_memoize(:assignees) do
if params[:assignee_ids]
::User.where(id: params[:assignee_ids])
elsif params[:assignee_username]
::User.where(username: params[:assignee_username])
else
[]
end
end
end
end
end
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