Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 18:08:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-28 18:08:36 +0300
commitfedf978f9aa1909ed7bb3fad767ad120a1c6bd7b (patch)
tree1bd0f0b301ad96feda1910abe34eb89c46cc55cd /app/finders/issuable_finder.rb
parentdb24ab2b72dbff24c201410a0561e929ae7e8061 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders/issuable_finder.rb')
-rw-r--r--app/finders/issuable_finder.rb25
1 files changed, 17 insertions, 8 deletions
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