2018-07-18 12:03:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-01-09 05:36:55 -05:00
|
|
|
module Search
|
2014-01-16 12:03:42 -05:00
|
|
|
class ProjectService
|
2014-01-09 05:36:55 -05:00
|
|
|
attr_accessor :project, :current_user, :params
|
|
|
|
|
|
|
|
def initialize(project, user, params)
|
|
|
|
@project, @current_user, @params = project, user, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-03-17 16:48:19 -04:00
|
|
|
Gitlab::ProjectSearchResults.new(current_user,
|
|
|
|
project,
|
2014-08-27 02:57:50 -04:00
|
|
|
params[:search],
|
|
|
|
params[:repository_ref])
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
|
|
|
|
def scope
|
2018-12-19 09:24:46 -05:00
|
|
|
@scope ||= begin
|
|
|
|
allowed_scopes = %w[notes issues merge_requests milestones wiki_blobs commits]
|
|
|
|
allowed_scopes << 'users' if Feature.enabled?(:users_search, default_enabled: true)
|
|
|
|
|
|
|
|
allowed_scopes.delete(params[:scope]) { 'blobs' }
|
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
end
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
Search::ProjectService.prepend_if_ee('EE::Search::ProjectService')
|