]> git.openstreetmap.org Git - rails.git/commitdiff
Use flat_map to collect way node ids in maps controller
authorAnton Khorev <tony29@yandex.ru>
Sat, 1 Feb 2025 17:36:07 +0000 (20:36 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 1 Feb 2025 17:36:07 +0000 (20:36 +0300)
app/controllers/api/maps_controller.rb

index 2aa25fdd74611ecb2e3323af46ede63b8f72e5fe..afba6faa4bbe4e53c4f9c8a5083ee656325a6b2e 100644 (file)
@@ -46,10 +46,7 @@ module Api
         way_ids = way_nodes.collect { |way_node| way_node.id[0] }
         ways = Way.preload(:way_nodes, :way_tags).find(way_ids)
 
-        list_of_way_nodes = ways.collect do |way|
-          way.way_nodes.collect(&:node_id)
-        end
-        list_of_way_nodes.flatten!
+        list_of_way_nodes = ways.flat_map { |way| way.way_nodes.map(&:node_id) }
       end
 
       # - [0] in case some thing links to node 0 which doesn't exist. Shouldn't actually ever happen but it does. FIXME: file a ticket for this