X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/c7061991e74a20cc0576a3afa269821a87178f77..5d3ecffa28510c867665001a7615559a185869c6:/app/controllers/api_controller.rb diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index d158019f3..25e1e3b95 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -141,7 +141,9 @@ class ApiController < ApplicationController # get ways # find which ways are needed ways = [] - if node_ids.length > 0 + if node_ids.empty? + list_of_way_nodes = [] + else way_nodes = WayNode.where(:node_id => node_ids) way_ids = way_nodes.collect { |way_node| way_node.id[0] } ways = Way.preload(:way_nodes, :way_tags).find(way_ids) @@ -150,15 +152,12 @@ class ApiController < ApplicationController way.way_nodes.collect(&:node_id) end list_of_way_nodes.flatten! - - else - list_of_way_nodes = [] 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 nodes_to_fetch = (list_of_way_nodes.uniq - node_ids) - [0] - if nodes_to_fetch.length > 0 + unless nodes_to_fetch.empty? nodes += Node.includes(:node_tags).find(nodes_to_fetch) end