2014-08-29 15:22:45 -04:00
|
|
|
module Search
|
|
|
|
class SnippetService
|
|
|
|
attr_accessor :current_user, :params
|
|
|
|
|
|
|
|
def initialize(user, params)
|
|
|
|
@current_user, @params = user, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2017-04-28 18:06:27 -04:00
|
|
|
snippets = SnippetsFinder.new(current_user).execute
|
2016-03-01 12:01:09 -05:00
|
|
|
|
|
|
|
Gitlab::SnippetSearchResults.new(snippets, params[:search])
|
2014-08-29 15:22:45 -04:00
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
|
|
|
|
def scope
|
|
|
|
@scope ||= %w[snippet_titles].delete(params[:scope]) { 'snippet_blobs' }
|
|
|
|
end
|
2014-08-29 15:22:45 -04:00
|
|
|
end
|
|
|
|
end
|