From: Nick Black Date: Wed, 23 Jan 2008 12:49:34 +0000 (+0000) Subject: updated rake task to grab 1000 records at a time X-Git-Tag: live~7953 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c93c841ed2c86af70d94e58d7781f2c1dc9fd5eb updated rake task to grab 1000 records at a time --- diff --git a/lib/tasks/populate_node_tags.rake b/lib/tasks/populate_node_tags.rake index 186b44e57..fe247da03 100644 --- a/lib/tasks/populate_node_tags.rake +++ b/lib/tasks/populate_node_tags.rake @@ -3,11 +3,12 @@ namespace 'db' do task :node_tags do require File.dirname(__FILE__) + '/../../config/environment' - #"created_by=YahooApplet 1.0;highway=traffic_signals" node_count = Node.count + limit = 1000 #the number of nodes to grab in one go + offset = 0 - for n in (0..node_count) - Node.find(:all, :limit => 1, :offset => n).each do |node| + while offset < node_count + Node.find(:all, :limit => limit, :offset => offset).each do |node| seq_id = 1 node.tags.split(';').each do |tag| nt = NodeTag.new @@ -35,6 +36,7 @@ namespace 'db' do version += 1 end end + offset += limit end end end