2014-01-09 10:36:55 +00:00
|
|
|
module Search
|
2014-01-16 17:03:42 +00:00
|
|
|
class GlobalService
|
2014-01-09 10:36:55 +00:00
|
|
|
attr_accessor :current_user, :params
|
|
|
|
|
|
|
|
def initialize(user, params)
|
|
|
|
@current_user, @params = user, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2014-01-19 18:55:59 +00:00
|
|
|
group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
|
2014-06-05 17:37:35 +00:00
|
|
|
projects = ProjectsFinder.new.execute(current_user)
|
2017-01-26 19:33:27 +00:00
|
|
|
|
|
|
|
if group
|
2017-01-30 09:35:28 +00:00
|
|
|
projects = projects.inside_path(group.full_path)
|
2017-01-26 19:33:27 +00:00
|
|
|
end
|
2014-01-09 10:36:55 +00:00
|
|
|
|
2016-03-17 20:48:19 +00:00
|
|
|
Gitlab::SearchResults.new(current_user, projects, params[:search])
|
2014-01-09 10:36:55 +00:00
|
|
|
end
|
2017-03-31 13:03:55 +00:00
|
|
|
|
|
|
|
def scope
|
|
|
|
@scope ||= %w[issues merge_requests milestones].delete(params[:scope]) { 'projects' }
|
|
|
|
end
|
2014-01-09 10:36:55 +00:00
|
|
|
end
|
|
|
|
end
|