Commit 1150ab80 authored by Wei-Meng Lee's avatar Wei-Meng Lee

Abstract author into private method

parent 3ef56667
......@@ -2,6 +2,8 @@
module Autocomplete
class UsersFinder
include Gitlab::Utils::StrongMemoize
# The number of users to display in the results is hardcoded to 20, and
# pagination is not supported. This ensures that performance remains
# consistent and removes the need for implementing keyset pagination to
......@@ -31,7 +33,7 @@ module Autocomplete
# Include current user if available to filter by "Me"
items.unshift(current_user) if prepend_current_user?
if (prepend_author? && author = User.find_by_id(author_id)) && author.active?
if prepend_author? && author&.active?
items.unshift(author)
end
end
......@@ -41,6 +43,12 @@ module Autocomplete
private
def author
strong_memoize(:author) do
User.find_by_id(author_id)
end
end
# Returns the users based on the input parameters, as an Array.
#
# This method is separate so it is easier to extend in EE.
......
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