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

Make a recursive call to get all records. #37

Closed
wants to merge 1 commit into from

Conversation

tsukaby
Copy link
Contributor

@tsukaby tsukaby commented Oct 3, 2019

If the recursive argument is set to true, all records can be retrieved.

[tsukaby@tsukamac zoho_hub]% bin/console
Refreshing token...
[1] pry(main)> class Contact < ZohoHub::BaseRecord;attributes(:id, :email);end
=> [:id, :email]
[2] pry(main)> Contact.all.count
=> 200
[3] pry(main)> Contact.all(recursive: true).count
=> 502
[4] pry(main)> Contact.where(params: {criteria: 'Email:starts_with:user'}).count
=> 200
[5] pry(main)> Contact.where(params: {criteria: 'Email:starts_with:user'}, recursive: true).count
=> 502

I am not a native English speaker.
If the English text is strange, it would be helpful if you taught me the correct text.

@@ -82,7 +96,7 @@ def blueprint_transition(id, transition_id, data = {})
new(id: id).blueprint_transition(transition_id, data)
end

def all(params = {})
def all(params: {}, recursive: false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this a breaking change...? 🤔

@tsukaby tsukaby force-pushed the feature/recursive_call_for_all branch from 6139d50 to a8319f0 Compare October 3, 2019 14:54
@tsukaby tsukaby force-pushed the feature/recursive_call_for_all branch from a8319f0 to a6e9835 Compare October 3, 2019 16:40
@@ -47,6 +47,11 @@ def data
data || @params
end

def info
info = @params[:info] if @params.dig(:info)
info || @params
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the purpose of this line 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method was created with reference to def data .

What about code like the following?

# return nil or info object
def info
  @params[:info]
end

@tsukaby tsukaby closed this Oct 11, 2023
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.

2 participants