Use filter instead of loop in visible node/way collections

This commit is contained in:
Anton Khorev 2025-02-01 20:19:00 +03:00
parent 560146d88c
commit b9f1e31122

View file

@ -57,15 +57,9 @@ module Api
nodes += Node.includes(:node_tags).find(nodes_to_fetch) unless nodes_to_fetch.empty?
@nodes = []
nodes.each do |node|
@nodes << node if node.visible?
end
@nodes = nodes.filter(&:visible?)
@ways = []
ways.each do |way|
@ways << way if way.visible?
end
@ways = ways.filter(&:visible?)
@relations = Relation.nodes(@nodes).visible +
Relation.ways(@ways).visible