013542965c
Instead of plucking IDs this class now uses ActiveRecord::Relation objects. Plucking IDs is problematic as searching for projects can lead to a huge amount of IDs being loaded into memory only to be used as an argument for another query (instead of just using a sub-query).
17 lines
459 B
Ruby
17 lines
459 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.execute(current_user)
|
|
projects = projects.in_namespace(group.id) if group
|
|
|
|
Gitlab::SearchResults.new(projects, params[:search])
|
|
end
|
|
end
|
|
end
|