Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scroll_each API to work with batches like find_each #1654

Open
willcosgrove opened this issue Oct 20, 2023 · 0 comments
Open

scroll_each API to work with batches like find_each #1654

willcosgrove opened this issue Oct 20, 2023 · 0 comments

Comments

@willcosgrove
Copy link
Contributor

The current Scroll API provides a method to iterate over each batch. But it does not provide a simple way of iterating over each element.

Much like ActiveRecord's find_in_batches has a corresponding find_each to hide away the batched nature of the iteration, I think scroll should have a corresponding scroll_each method. The name is debatable but it brought to mind the existing ActiveRecord API.

A simple implementation like this is what I'm imagining:

def scroll_each
  scroll do |batch|
    batch.each do |element|
      yield element
    end
  end
end

I'm happy to submit a PR if you're interested in something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant