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

Can pagination be automatic? #40

Open
nebulous opened this issue Feb 14, 2013 · 5 comments
Open

Can pagination be automatic? #40

nebulous opened this issue Feb 14, 2013 · 5 comments

Comments

@nebulous
Copy link
Contributor

Filed as an issue because I'm not sure if it's worthy of pull request, but the following has worked reasonably well for me to automatically dig thru pages. 1c3ba0a

@sergeyromanov
Copy link

Since every page is a separate request this feature can cause you inadvertently exceed request rate limit for really large lists. And I don't think you want that.

@schwern
Copy link
Contributor

schwern commented Oct 29, 2014

I agree with @sergeyromanov, pagination is there for a reason. For example, you really don't want to slurp info about all commits at once.

The solution is no good, but the problem is totally valid. The user must always consider pagination for any list call, but it's poorly integrated into Net::GitHub::V3. One solution would be to use an iterator for lists...

my $issue_iter = $gh->issue->repos_issues;
while (my $issue = $issue_iter->next) {
    # do something with $issue
}

Or a callback.

my $issue_iter = $gh->issue->repos_issues(
    callback => sub {
        my $issue = shift;
        # do something with $issue
    }
);

I prefer the iterator, it offers more control to the user.

An advantage is to reduce the need to ask for another page just to see if you're done. The iteration can be smart enough to notice that the last page returned less than per_page elements to know that it's done.

@sergeyromanov
Copy link

@nebulous @schwern Pithub (aka yet another GitHub API wrapper) has an explicit auto_pagination attribute, which you can toggle on at your own risk.

@0Adam7Cabala0
Copy link

E

@kablamo
Copy link

kablamo commented Jul 8, 2015

I would like to see auto pagination as an attribute to the constructor ala Pithub. Maybe the user does want all the commits. Given the rate limiting features of this module, I don't see why it would be a problem.

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

No branches or pull requests

5 participants