Sha256: 6a02a81a40cd2ccde1cc35c9c7cc6c81f20d194258c8934d52ad9d130d3b1e1e

Contents?: true

Size: 684 Bytes

Versions: 3

Compression:

Stored size: 684 Bytes

Contents

require 'progress'

module ActiveRecord
  module BatchesWithProgress
    # run `find_each` with progress
    def find_each_with_progress(options = {})
      Progress.start(name.tableize, count(options)) do
        find_each do |model|
          Progress.step do
            yield model
          end
        end
      end
    end

    # run `find_in_batches` with progress
    def find_in_batches_with_progress(options = {})
      Progress.start(name.tableize, count(options)) do
        find_in_batches do |batch|
          Progress.step batch.length do
            yield batch
          end
        end
      end
    end
  end

  class Base
    extend BatchesWithProgress
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
progress-3.0.2 lib/progress/active_record.rb
progress-3.0.1 lib/progress/active_record.rb
progress-3.0.0 lib/progress/active_record.rb