Class: Search::ProjectService
- Inherits:
-
Object
- Object
- Search::ProjectService
- Includes:
- Gitlab::Utils::StrongMemoize, Filter
- Defined in:
- app/services/search/project_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#params ⇒ Object
Returns the value of attribute params.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #allowed_scopes ⇒ Object
- #execute ⇒ Object
-
#initialize(user, project, params) ⇒ ProjectService
constructor
A new instance of ProjectService.
- #scope ⇒ Object
Constructor Details
#initialize(user, project, params) ⇒ ProjectService
Returns a new instance of ProjectService.
10 11 12 13 14 |
# File 'app/services/search/project_service.rb', line 10 def initialize(user, project, params) @current_user = user @project = project @params = params.dup end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
8 9 10 |
# File 'app/services/search/project_service.rb', line 8 def current_user @current_user end |
#params ⇒ Object
Returns the value of attribute params.
8 9 10 |
# File 'app/services/search/project_service.rb', line 8 def params @params end |
#project ⇒ Object
Returns the value of attribute project.
8 9 10 |
# File 'app/services/search/project_service.rb', line 8 def project @project end |
Instance Method Details
#allowed_scopes ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/services/search/project_service.rb', line 27 def allowed_scopes Search::Scopes.available_for_context( context: :project, container: searched_container, requested_search_type: params[:search_type] ) end |
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/search/project_service.rb', line 16 def execute Gitlab::ProjectSearchResults.new(current_user, params[:search], project: project, repository_ref: params[:repository_ref], order_by: params[:order_by], sort: params[:sort], filters: filters ) end |
#scope ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/search/project_service.rb', line 35 def scope = Search::Navigation.new(user: current_user, project: project) scope = params[:scope] return scope if allowed_scopes.include?(scope) && .tab_enabled_for_project?(scope.to_sym) if ::Gitlab::CurrentSettings.custom_default_search_scope_set? && allowed_scopes.include?(::Gitlab::CurrentSettings.default_search_scope) && .tab_enabled_for_project?(::Gitlab::CurrentSettings.default_search_scope.to_sym) return ::Gitlab::CurrentSettings.default_search_scope end allowed_scopes.find do |s| .tab_enabled_for_project?(s.to_sym) end end |