Sized enumerator - #13938
Merged
Merged
Conversation
Member
|
@marcandre seems good to me. Could you squash the commits that add the feature? The two obsolete removals commits are good as separated commits. We will need a CHANGELOG entry too. |
Contributor
Author
|
Right, forgot about the CHANGELOG, sorry. Done. |
Member
|
Thanks. About the squash it is fine to me. I agree with you that they are independent. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a lazy size block to enumerators returned by
Batches#find_each,find_in_batches,Result#eachandEnumerable#index_by.This allows, for example using my gem
with_progress:This will print a progress bar with an estimated time left, etc, while still loading the records in batches.
The PR also has a couple of test cleanup commits at the beginning.
Note: In Ruby 1.9, there is no
Enumerator#size, so the test is conditional on that. The block given toto_enumis ignored in 1.9, so no specific treatment is needed.