b996a82ff4
Extended ProjectFinder in order to handle the following options: - current_user - which user use - project_ids_relation: int[] - project ids to use - params: - trending: boolean - non_public: boolean - starred: boolean - sort: string - visibility_level: int - tags: string[] - personal: boolean - search: string - non_archived: boolean GroupProjectsFinder now inherits from ProjectsFinder. Changed the code in order to use the new available options.
28 lines
692 B
Ruby
28 lines
692 B
Ruby
module Search
|
|
class GlobalService
|
|
attr_accessor :current_user, :params
|
|
|
|
def initialize(user, params)
|
|
@current_user, @params = user, params.dup
|
|
end
|
|
|
|
def execute
|
|
group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
|
|
projects = ProjectsFinder.new(current_user: current_user).execute
|
|
|
|
if group
|
|
projects = projects.inside_path(group.full_path)
|
|
end
|
|
|
|
Gitlab::SearchResults.new(current_user, projects, params[:search])
|
|
end
|
|
|
|
def scope
|
|
@scope ||= begin
|
|
allowed_scopes = %w[issues merge_requests milestones]
|
|
|
|
allowed_scopes.delete(params[:scope]) { 'projects' }
|
|
end
|
|
end
|
|
end
|
|
end
|