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
|
2014-01-19 13:55:59 -05:00
|
|
|
group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
|
2014-06-05 13:37:35 -04:00
|
|
|
projects = ProjectsFinder.new.execute(current_user)
|
2017-01-26 14:33:27 -05:00
|
|
|
|
|
|
|
if group
|
|
|
|
ids = group.descendants.push(group.id)
|
|
|
|
projects = projects.in_namespace(ids)
|
|
|
|
end
|
2014-01-09 05:36:55 -05:00
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|