2014-01-09 05:36:55 -05:00
|
|
|
module Search
|
2014-01-16 12:03:42 -05:00
|
|
|
class GlobalService
|
2014-01-09 05:36:55 -05:00
|
|
|
attr_accessor :current_user, :params
|
|
|
|
|
|
|
|
def initialize(user, params)
|
|
|
|
@current_user, @params = user, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2016-03-17 16:48:19 -04:00
|
|
|
Gitlab::SearchResults.new(current_user, projects, params[:search])
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
|
2017-04-13 11:20:04 -04:00
|
|
|
def projects
|
|
|
|
@projects ||= ProjectsFinder.new(current_user: current_user).execute
|
|
|
|
end
|
|
|
|
|
2017-03-31 09:03:55 -04:00
|
|
|
def scope
|
2017-04-04 07:57:16 -04:00
|
|
|
@scope ||= begin
|
|
|
|
allowed_scopes = %w[issues merge_requests milestones]
|
|
|
|
|
|
|
|
allowed_scopes.delete(params[:scope]) { 'projects' }
|
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
end
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
|
|
|
end
|