X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/ef7f3d800cbdd49b692df10d312e5fd880e2e938..4607ac2d30806fbfb00969df92823154df4a9a2f:/lib/tasks/add_version_to_nodes.rake diff --git a/lib/tasks/add_version_to_nodes.rake b/lib/tasks/add_version_to_nodes.rake index c0fac49b7..cdcf13a3e 100644 --- a/lib/tasks/add_version_to_nodes.rake +++ b/lib/tasks/add_version_to_nodes.rake @@ -1,20 +1,18 @@ -namespace 'db' do - desc 'Adds a version number to the nodes table' +namespace "db" do + desc "Adds a version number to the nodes table" task :node_version do - require File.dirname(__FILE__) + '/../../config/environment' + require File.dirname(__FILE__) + "/../../config/environment" increment = 1000 offset = 0 - id_max = OldNode.find(:first, :order => 'id desc').id + id_max = OldNode.find(:first, :order => "id desc").id while offset < (id_max + increment) hash = {} # should be offsetting not selecting - OldNode.find(:all, :limit => increment, :offset => offset, :order => 'timestamp').each do |node| - if hash[node.id].nil? - hash[node.id] = [] - end + OldNode.find(:all, :limit => increment, :offset => offset, :order => "timestamp").each do |node| + hash[node.id] ||= [] hash[node.id] << node end