Abstract author into private method
This commit is contained in:
parent
3ef5666783
commit
1150ab80a0
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
module Autocomplete
|
module Autocomplete
|
||||||
class UsersFinder
|
class UsersFinder
|
||||||
|
include Gitlab::Utils::StrongMemoize
|
||||||
|
|
||||||
# The number of users to display in the results is hardcoded to 20, and
|
# The number of users to display in the results is hardcoded to 20, and
|
||||||
# pagination is not supported. This ensures that performance remains
|
# pagination is not supported. This ensures that performance remains
|
||||||
# consistent and removes the need for implementing keyset pagination to
|
# 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"
|
# Include current user if available to filter by "Me"
|
||||||
items.unshift(current_user) if prepend_current_user?
|
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)
|
items.unshift(author)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -41,6 +43,12 @@ module Autocomplete
|
||||||
|
|
||||||
private
|
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.
|
# Returns the users based on the input parameters, as an Array.
|
||||||
#
|
#
|
||||||
# This method is separate so it is easier to extend in EE.
|
# This method is separate so it is easier to extend in EE.
|
||||||
|
|
Loading…
Reference in New Issue