X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/6f6e827702fb2e56c0f7cd6aaf43d98f9c7f5fb2..45ec042c90d00f8e7b116fa2630af5722111fb2b:/lib/tasks/add_version_to_nodes.rake?ds=sidebyside diff --git a/lib/tasks/add_version_to_nodes.rake b/lib/tasks/add_version_to_nodes.rake index 1ec831234..5301738c0 100644 --- a/lib/tasks/add_version_to_nodes.rake +++ b/lib/tasks/add_version_to_nodes.rake @@ -1,19 +1,20 @@ namespace 'db' do - desc 'Populate the node_tags table' + desc 'Adds a version number to the nodes table' task :node_version do require File.dirname(__FILE__) + '/../../config/environment' - lower_bound = 0 - increment = 100 - node_count = OldNode.count - puts node_count + increment = 1000 + offset = 0 + id_max = OldNode.find(:first, :order => 'id desc').id - while lower_bound < node_count - upper_bound = lower_bound + increment - hash = {} - - OldNode.find(:all, :conditions => ['id >= ? AND id < ?',lower_bound, upper_bound], :order => 'timestamp').each do |node| - hash[node.id] = [] if hash[node.id].nil? + 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 hash[node.id] << node end @@ -28,12 +29,12 @@ namespace 'db' do temp_old_node.visible = node.visible temp_old_node.timestamp = node.timestamp temp_old_node.tile = node.tile - temp_old_node.version = node.version + temp_old_node.version = n temp_old_node.save! || raise n +=1 end end - lower_bound += increment + offset += increment end end end