This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Relation | |
def pluck_in_batches(*columns, batch_size: 1000, start: nil) | |
relation = self | |
relation = relation.where(table[primary_key].gteq(start)) if start | |
batch_order = "#{table.name}.#{primary_key} ASC" | |
relation = relation.reorder(batch_order) | |
loop do | |
batch = relation.limit(batch_size).pluck(*columns, primary_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Call scopes directly from your URL params: | |
# | |
# @products = Product.filter(params.slice(:status, :location, :starts_with)) | |
module Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Call the class methods with names based on the keys in <tt>filtering_params</tt> | |
# with their associated values. For example, "{ status: 'delayed' }" would call |