Skip to content

Fix Pagination issue - #55

Closed
justinburger wants to merge 1 commit into
KnpLabs:masterfrom
justinburger:master
Closed

justinburger wants to merge 1 commit into
KnpLabs:masterfrom
justinburger:master

Conversation

@justinburger

Copy link
Copy Markdown

The newer versions of the Github API includes pagination. It means,
without passing per_page, it's defaulting to the first 25 items. This
causes issues if a user has more than 25 repositories. Or more than 25
open pull requests.

The solution I implemented is very simple, but it's been tested with large volume accounts for both repositories and pull requests.

The newer versions of the Github API includes pagination. It means,
without passing per_page, it's defaulting to the first 25 items. This
causes issues if a user has more than 25 repositories. Or more than 25
open pull requests.
Comment thread lib/Github/Client.php

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not 30? That is the default from github.. and the limit is 100...
http://developer.github.com/v3/#pagination

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be 30 as it's default value or null as it's not required by GH.

@dbu

dbu commented May 26, 2013

Copy link
Copy Markdown

this PR only works if you do not get more than the hard limit of the github api. which is as verschoof notes usually set at 100. and some projects could have more than even 500 items anyways, for example when fetching closed issues.

note that there is also #49 and #53 that both are about pagination.

in my opinion, we either need the option to make this library fetch all, no matter how many pages, or to somehow expose the paging to the user of the library. having to change the signature of every method that goes to the api client sounds painful, but maybe its really the only clean thing to do. but additionally we would still need to know if there are more pages. so maybe having a PagingClient and set limit and page on it before the request, then doing the request and then asking the client if there would be a next page is actually a better solution...

@KnpLabs would be really cool if you could give some input as to what you prefer. it seems there are enough people around willing to contribute, but you should define the architecture you want.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be different, this should go to setOption() not in get().

@pilot

pilot commented Jun 5, 2013

Copy link
Copy Markdown
Contributor

@justinburger fix by comments and fix a test, should be passed.

@dbu, @verschoof, @justinburger, @stloyd let's discus bout pagination in a general, so put a page params under each method looks a quite painful and having global per_page looks a good, but for me both solutions is suit, cause if global per_page restriction does not suit me for all pr fetch I've just can use a local method restriction as for other methods.

@dbu

dbu commented Jun 7, 2013

Copy link
Copy Markdown

the main issue i see with the method parameters as in #53 is: how will a client do pagination? count the results and guess that if he got the maximum there could be a next page and try that?

i think a neat solution could be to have a PagingClient that the user interacts with. that would solve the problem generically. on that client you could set the offset and limit for the next request, then have the request executed. ideally it would transparently get multiple pages if your limit is higher then the hard limit of github.

if we want the #53 approach the client could just expose the fact if there is a next page, but otherwise you go through the normal methods. but all method signatures need to be updated. as the params are optional, i think we could do that without bc breaks for the user so its just some work, but no big issue for the users of this lib.

@ramondelafuente

Copy link
Copy Markdown
Contributor

@dbu We took exactly that approach, only we called it a "ResultPaginator" (@verschoof):

https://github.com/Future500BV/php-github-api/commit/3683986823ed7995d0ff6f20074f821eba1dd050

We did not submit a pull request because it was a work-in-progress. Feel free to take a look, we'd be happy to finish this or at least bring it closer to being merged.

@A973C

A973C commented Jun 22, 2013

Copy link
Copy Markdown

Hi!
Thank you for this great repo!

Is pagination already implemented for Repos or Gists list? Can't see any information.

@dbu

dbu commented Jul 1, 2013

Copy link
Copy Markdown

This looks like a very cool approach to me that does not need to rewrite the whole api. Would be awesome if you could polish this a bit and do a PR! Not sure if i would find time anytime soon

----- Reply message -----
Von: "Ramon de la Fuente" notifications@github.com
An: "KnpLabs/php-github-api" php-github-api@noreply.github.com
Cc: "David Buchmann" david@liip.ch
Betreff: [php-github-api] Fix Pagination issue (#55)
Datum: Mi., Jun. 19, 2013 00:40
@dbu We took exactly that approach, only we called it a "ResultPaginator" (@verschoof):

Future500BV@3683986

We did not submit a pull request because it was a work-in-progress. Feel free to take a look, we'd be happy to finish this or at least bring it closer to being merged.

—
Reply to this email directly or view it on GitHub.

@ramondelafuente

Copy link
Copy Markdown
Contributor

Will do. Might be next week though.

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.

7 participants