Created
October 12, 2018 14:13
-
-
Save tom-lord/1a89a691f295bce24621ec267c144f9a to your computer and use it in GitHub Desktop.
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
# Snippets taken from: | |
# https://github.com/rails/rails/blob/fc5dd0b85189811062c85520fd70de8389b55aeb/activerecord/lib/active_record/relation/batches.rb#L201 | |
def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore: nil) | |
relation = self | |
# ... | |
batch_limit = of | |
# ... | |
relation = relation.reorder(batch_order).limit(batch_limit) | |
relation = apply_limits(relation, start, finish) | |
# ... | |
end | |
def batch_order | |
arel_attribute(primary_key).asc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment