-namespace 'db' do
- desc 'Populate the node_tags table'
- task :node_version do
- require File.dirname(__FILE__) + '/../../config/environment'
-
- lower_bound = 0
- increment = 100
- node_count = OldNode.count
- puts node_count
-
- 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?
- hash[node.id] << node
+namespace "db" do
+ desc "Adds a version number to the nodes table"
+ task :node_version do
+ require File.dirname(__FILE__) + "/../../config/environment"
+
+ increment = 1000
+ offset = 0
+ 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|
+ hash[node.id] ||= []
+ hash[node.id] << node