Class: Autocomplete::UsersFinder
- Inherits:
-
Object
- Object
- Autocomplete::UsersFinder
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/finders/autocomplete/users_finder.rb
Constant Summary collapse
- LIMIT =
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 ensure good performance.
20
Instance Attribute Summary collapse
-
#author_id ⇒ Object
readonly
Returns the value of attribute author_id.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#filter_by_current_user ⇒ Object
readonly
Returns the value of attribute filter_by_current_user.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
-
#skip_users ⇒ Object
readonly
Returns the value of attribute skip_users.
-
#todo_filter ⇒ Object
readonly
Returns the value of attribute todo_filter.
-
#todo_state_filter ⇒ Object
readonly
Returns the value of attribute todo_state_filter.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(params:, current_user:, project:, group:) ⇒ UsersFinder
constructor
A new instance of UsersFinder.
Methods included from Gitlab::Utils::StrongMemoize
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(params:, current_user:, project:, group:) ⇒ UsersFinder
Returns a new instance of UsersFinder.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/finders/autocomplete/users_finder.rb', line 17 def initialize(params:, current_user:, project:, group:) @current_user = current_user @project = project @group = group @search = params[:search] @skip_users = params[:skip_users] @author_id = params[:author_id] @todo_filter = params[:todo_filter] @todo_state_filter = params[:todo_state_filter] @filter_by_current_user = params[:current_user] end |
Instance Attribute Details
#author_id ⇒ Object (readonly)
Returns the value of attribute author_id
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def @author_id end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def current_user @current_user end |
#filter_by_current_user ⇒ Object (readonly)
Returns the value of attribute filter_by_current_user
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def filter_by_current_user @filter_by_current_user end |
#group ⇒ Object (readonly)
Returns the value of attribute group
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def group @group end |
#project ⇒ Object (readonly)
Returns the value of attribute project
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def project @project end |
#search ⇒ Object (readonly)
Returns the value of attribute search
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def search @search end |
#skip_users ⇒ Object (readonly)
Returns the value of attribute skip_users
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def skip_users @skip_users end |
#todo_filter ⇒ Object (readonly)
Returns the value of attribute todo_filter
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def todo_filter @todo_filter end |
#todo_state_filter ⇒ Object (readonly)
Returns the value of attribute todo_state_filter
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def todo_state_filter @todo_state_filter end |
Instance Method Details
#execute ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/finders/autocomplete/users_finder.rb', line 29 def execute items = limited_users if search.blank? # Include current user if available to filter by "Me" items.unshift(current_user) if prepend_current_user? if && &.active? items.unshift() end end items.uniq end |