Sha256: f36ca3085b96cdab0f3482ac110b358ed1ba8f7bb791c2db237c3667f643694e
Contents?: true
Size: 487 Bytes
Versions: 5
Compression:
Stored size: 487 Bytes
Contents
require 'active_support/concern' module Journey::Resource::BatchWhere extend ActiveSupport::Concern included do def self.batch_where(clauses, batch_size=100) total_count = count_multiple(clauses) query_count = (total_count / batch_size.to_f).ceil.to_i (0 ... query_count).to_a.map do |batch_index| where_multiple clauses.merge({ limit: batch_size, skip: batch_index * batch_size }) end.flatten end end end
Version data entries
5 entries across 5 versions & 1 rubygems