Module: ActiveGraph::Migrations::Helpers::IdProperty

Extended by:
ActiveSupport::Concern
Included in:
ActiveGraph::Migration::AddIdProperty, Base
Defined in:
lib/active_graph/migrations/helpers/id_property.rb

Instance Method Summary collapse

Instance Method Details

#populate_id_property(label) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/active_graph/migrations/helpers/id_property.rb', line 7

def populate_id_property(label)
  model = label.to_s.constantize
  max_per_batch = (ENV['MAX_PER_BATCH'] || default_max_per_batch).to_i

  last_time_taken = nil

  until (nodes_left = idless_count(label, model.primary_key)) == 0
    print_status(last_time_taken, max_per_batch, nodes_left)

    count = [nodes_left, max_per_batch].min
    last_time_taken = Benchmark.realtime do
      max_per_batch = id_batch_set(label, model.primary_key, Array.new(count) { new_id_for(model) }, count)
    end
  end
end