Skip to content

[MODEL] Support :scope, :query and :preprocess importing options for Mongoid #786

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

Merged
merged 2 commits into from
Aug 17, 2018

Conversation

Seitk
Copy link
Contributor

@Seitk Seitk commented Apr 6, 2018

The elasticsearch model readme said It's possible to import only records from scope or query and preprocess batch data but it's not implemented

@Seitk Seitk force-pushed the 5.x branch 3 times, most recently from 022a071 to 8f81fc5 Compare April 6, 2018 05:48
@karmi
Copy link
Contributor

karmi commented Apr 25, 2018

@Seitk , this sounds right! Since we're planning some re-focus to the libraries soon, I'd rather not merge it now, in a couple of weeks we should have more capacity to give your PR and other PRs more attention...

@@ -64,9 +64,16 @@ module Importing
#
def __find_in_batches(options={}, &block)
options[:batch_size] ||= 1_000
query = options.delete(:query)
named_scope = options.delete(:scope)
preprocess = options.delete(:preprocess)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind if we just set the :query, :scope and :preprocess options instead of deleting them from the options hash? I'd rather not mutate the options that the user passes to the #import method. Thanks!

@estolfo
Copy link
Contributor

estolfo commented Aug 16, 2018

Hi @Seitk I added a comment, let me know what you think so we can get this merged.
Also, can you please rebase and open the PR against 6.x? Thanks!

@Seitk Seitk force-pushed the 5.x branch 2 times, most recently from 013669b to c09746d Compare August 16, 2018 15:39
@Seitk Seitk changed the base branch from 5.x to 6.x August 16, 2018 15:41
@Seitk Seitk changed the base branch from 6.x to 5.x August 16, 2018 15:42
@Seitk
Copy link
Contributor Author

Seitk commented Aug 16, 2018

@estolfo updated, should i change base on this PR or open a new one lol?

@estolfo
Copy link
Contributor

estolfo commented Aug 16, 2018

@Seitk Sure you can update this PR, thanks!

@estolfo
Copy link
Contributor

estolfo commented Aug 16, 2018

@Seitk Also, perhaps you want to follow what I've done here to use the default_scope on the model? It seems that we should be consistent between the Mongoid and ActiveRecord adapters.

@Seitk Seitk force-pushed the 5.x branch 3 times, most recently from 4018be8 to 656ca2c Compare August 17, 2018 01:56
@Seitk
Copy link
Contributor Author

Seitk commented Aug 17, 2018

@estolfo The default scope is supported by default with the "all" criteria, added integration test for mongoid with default scope anyway

@Seitk
Copy link
Contributor Author

Seitk commented Aug 17, 2018

btw I am using "5.x" for a production service, i will create another PR for "6.x" separately

@estolfo
Copy link
Contributor

estolfo commented Aug 17, 2018

@Seitk Thanks for the reminder about the default_scope via all. I've updated my pull request - it turns out that it's working as expected without code changes.
In any case, thanks for adding the test for default_scope in this PR.
The changes for the 6.x should be identical, I don't think any of this code changed in the 6.x branch so I look forward to receiving another PR. Thanks!

@estolfo estolfo merged commit bfdd224 into elastic:5.x Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants