Remove ids collected in parallel to model instances in map api

This commit is contained in:
Anton Khorev 2025-02-01 20:09:38 +03:00
parent 434b57ab45
commit 560146d88c

View file

@ -57,26 +57,18 @@ module Api
nodes += Node.includes(:node_tags).find(nodes_to_fetch) unless nodes_to_fetch.empty? nodes += Node.includes(:node_tags).find(nodes_to_fetch) unless nodes_to_fetch.empty?
visible_nodes = {}
@nodes = [] @nodes = []
nodes.each do |node| nodes.each do |node|
if node.visible? @nodes << node if node.visible?
visible_nodes[node.id] = node
@nodes << node
end
end end
@ways = [] @ways = []
way_ids = []
ways.each do |way| ways.each do |way|
if way.visible? @ways << way if way.visible?
way_ids << way.id
@ways << way
end
end end
@relations = Relation.nodes(visible_nodes.keys).visible + @relations = Relation.nodes(@nodes).visible +
Relation.ways(way_ids).visible Relation.ways(@ways).visible
# we do not normally return the "other" partners referenced by an relation, # we do not normally return the "other" partners referenced by an relation,
# e.g. if we return a way A that is referenced by relation X, and there's # e.g. if we return a way A that is referenced by relation X, and there's