Class: Search::GlobalService
- Inherits:
-
Object
- Object
- Search::GlobalService
- Includes:
- Gitlab::Utils::StrongMemoize, Filter
- Defined in:
- app/services/search/global_service.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_SCOPE =
'projects'
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #allowed_scopes ⇒ Object
- #execute ⇒ Object
-
#initialize(user, params) ⇒ GlobalService
constructor
A new instance of GlobalService.
-
#projects ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
- #scope ⇒ Object
Constructor Details
#initialize(user, params) ⇒ GlobalService
12 13 14 15 |
# File 'app/services/search/global_service.rb', line 12 def initialize(user, params) @current_user = user @params = params.dup end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
10 11 12 |
# File 'app/services/search/global_service.rb', line 10 def current_user @current_user end |
#params ⇒ Object
Returns the value of attribute params.
10 11 12 |
# File 'app/services/search/global_service.rb', line 10 def params @params end |
Instance Method Details
#allowed_scopes ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/services/search/global_service.rb', line 32 def allowed_scopes Search::Scopes.available_for_context( context: :global, container: searched_container, requested_search_type: params[:search_type] ) end |
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/services/search/global_service.rb', line 17 def execute Gitlab::SearchResults.new(current_user, params[:search], projects, order_by: params[:order_by], sort: params[:sort], filters: filters ) end |
#projects ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
28 29 30 |
# File 'app/services/search/global_service.rb', line 28 def projects @projects ||= ::ProjectsFinder.new(current_user: current_user).execute.preload(:topics, :project_topics, :route) end |
#scope ⇒ Object
40 41 42 |
# File 'app/services/search/global_service.rb', line 40 def scope allowed_scopes.include?(params[:scope]) ? params[:scope] : default_search_scope end |