Improve query on GeoNode#project_ids

parent 92409d42
......@@ -111,7 +111,11 @@ class GeoNode < ActiveRecord::Base
def project_ids
return unless namespaces.presence
namespaces.flat_map { |namespace| namespace.all_projects.select(:id).pluck(:id) }.uniq
relations = namespaces.map { |namespace| namespace.all_projects.select(:id) }
Project.unscoped
.from("(#{Gitlab::SQL::Union.new(relations).to_sql}) #{Project.table_name}")
.pluck(:id)
end
def lfs_objects
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment