From fedf978f9aa1909ed7bb3fad767ad120a1c6bd7b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 28 Jan 2020 15:08:36 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/finders/issuable_finder.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'app/finders/issuable_finder.rb') diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 194d7da1cab..6d5b1ca3bc5 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -314,18 +314,21 @@ class IssuableFinder params[:assignee_username].present? end - # rubocop: disable CodeReuse/ActiveRecord def assignee - return @assignee if defined?(@assignee) + assignees.first + end - @assignee = + # rubocop: disable CodeReuse/ActiveRecord + def assignees + strong_memoize(:assignees) do if assignee_id? - User.find_by(id: params[:assignee_id]) + User.where(id: params[:assignee_id]) elsif assignee_username? - User.find_by_username(params[:assignee_username]) + User.where(username: params[:assignee_username]) else - nil + User.none end + end end # rubocop: enable CodeReuse/ActiveRecord @@ -415,7 +418,7 @@ class IssuableFinder # These are "helper" params that are required inside the NOT to get the right results. They usually come in # at the top-level params, but if they do come in inside the `:not` params, they should take precedence. not_helpers = params.slice(*NEGATABLE_PARAMS_HELPER_KEYS).merge(params[:not].slice(*NEGATABLE_PARAMS_HELPER_KEYS)) - not_param = { key => value }.with_indifferent_access.merge(not_helpers) + not_param = { key => value }.with_indifferent_access.merge(not_helpers).merge(not_query: true) items_to_negate = self.class.new(current_user, not_param).execute @@ -543,6 +546,8 @@ class IssuableFinder # rubocop: enable CodeReuse/ActiveRecord def by_assignee(items) + return items.assigned_to(assignees) if not_query? && assignees.any? + if filter_by_no_assignee? items.unassigned elsif filter_by_any_assignee? @@ -624,7 +629,7 @@ class IssuableFinder elsif filter_by_any_label? items.any_label else - items.with_label(label_names, params[:sort]) + items.with_label(label_names, params[:sort], not_query: not_query?) end items @@ -673,4 +678,8 @@ class IssuableFinder def min_access_level ProjectFeature.required_minimum_access_level(klass) end + + def not_query? + !!params[:not_query] + end end -- cgit v1.2.3