Class: Search::ProjectService
- Inherits:
-
Object
- Object
- Search::ProjectService
- Includes:
- Gitlab::Utils::StrongMemoize, Filter
- Defined in:
- app/services/search/project_service.rb
Constant Summary collapse
- ALLOWED_SCOPES =
%w[blobs issues merge_requests wiki_blobs commits notes milestones users].freeze
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_or_projects, params) ⇒ ProjectService
constructor
A new instance of ProjectService.
- #scope ⇒ Object
Constructor Details
#initialize(user, project_or_projects, params) ⇒ ProjectService
Returns a new instance of ProjectService.
12 13 14 15 16 |
# File 'app/services/search/project_service.rb', line 12 def initialize(user, project_or_projects, params) @current_user = user @project = project_or_projects @params = params.dup end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
10 11 12 |
# File 'app/services/search/project_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/project_service.rb', line 10 def params @params end |
#project ⇒ Object
Returns the value of attribute project.
10 11 12 |
# File 'app/services/search/project_service.rb', line 10 def project @project end |
Instance Method Details
#allowed_scopes ⇒ Object
29 30 31 |
# File 'app/services/search/project_service.rb', line 29 def allowed_scopes ALLOWED_SCOPES end |
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/search/project_service.rb', line 18 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
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/search/project_service.rb', line 33 def scope strong_memoize(:scope) do = Search::Navigation.new(user: current_user, project: project) scope = params[:scope] next scope if allowed_scopes.include?(scope) && .tab_enabled_for_project?(scope.to_sym) allowed_scopes.find do |s| .tab_enabled_for_project?(s.to_sym) end end end |