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.
-
#push_code ⇒ Object
readonly
Returns the value of attribute push_code.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
-
#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.
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 28 |
# 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] @author_id = params[:author_id] @todo_filter = params[:todo_filter] @todo_state_filter = params[:todo_state_filter] @filter_by_current_user = params[:current_user] @states = params[:states] || ['active'] @push_code = params[:push_code] 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 |
#push_code ⇒ Object (readonly)
Returns the value of attribute push_code.
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def push_code @push_code 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 |
#states ⇒ Object (readonly)
Returns the value of attribute states.
13 14 15 |
# File 'app/finders/autocomplete/users_finder.rb', line 13 def states @states 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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/finders/autocomplete/users_finder.rb', line 30 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? items.unshift() if && &.active? && !&.import_user? && !&.placeholder? end items = filter_users_by_push_ability(items) items.uniq.tap do |unique_items| preload_associations(unique_items) end end |