gitlab-org--gitlab-foss/app/services/search/project_service.rb

41 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Search
class ProjectService
include Gitlab::Utils::StrongMemoize
ALLOWED_SCOPES = %w(notes issues merge_requests milestones wiki_blobs commits users).freeze
attr_accessor :project, :current_user, :params
def initialize(project, user, params)
@project = project
@current_user = user
@params = params.dup
end
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: { confidential: params[:confidential], state: params[:state] }
)
end
2017-03-31 09:03:55 -04:00
def allowed_scopes
ALLOWED_SCOPES
end
2018-12-19 09:24:46 -05:00
def scope
strong_memoize(:scope) do
allowed_scopes.include?(params[:scope]) ? params[:scope] : 'blobs'
2018-12-19 09:24:46 -05:00
end
2017-03-31 09:03:55 -04:00
end
end
end
Search::ProjectService.prepend_if_ee('EE::Search::ProjectService')