-
Notifications
You must be signed in to change notification settings - Fork 65
Pagination support for lists #66
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
Conversation
|
Try to use my https://github.com/svetlyak40wt/pagerator/ because it is able to replace all these crapy lines of code with just one line: But you have to know default page size, which is 30 for GitHub API v3. |
|
By the way, some time ago, I found that API v2 does not support "page" argument in few places. I don't remember which exactly, but they won't fix it and advice to use API v3, where nice pageration is available, using "Link" http header. |
|
Ok, good to know for the page argument forbidden in some calls. We'll have to check all of them... :-/ For the pagerator, i don't know all page size in the api v2, the documentation is poor or inexact. Thanks for your comments. PS : btw header are present in the api v2, with x-next, x-prev and x-last, but the headers are ignored too deeply in the python-github2 code |
|
PS : btw all my "crapy lines of code" (i kwno they are), are in one and only one place, in a method in my code called each time i want all the content. |
|
I just removed the page parameter for a lot of lists. Here the only ones that seem to support it :
All return a empty list when the given page is too big, except for the list of commit which raise a 404. And all return max 100 items per request (documentation says 30 sometimes) And all search query return max 100 results, without pagination. |
|
@twidi, by the way, I'm going to build something very close to yours repos.io, but with slightly different feature set. And I'll be using "requests" library and raw GitHub API v3 without any wrappers. If you are interested in my thoughts about the project, subscribe to my blog: http://dev.svetlyak.ru |
|
@svetlyak40wt cool, let me know ! (but for now i can't read russian) |
|
I'm trying to translate most posts in english too. Subscribe on translations only: http://dev.svetlyak.ru/feeds/all-en Today I'll publish a report with GitHub's users and reps statistics. |
|
Haven't spent much time looking at this... but I think this should be merged. There are a few problems that need fixing before that can happen:
If I get time later today or tomorrow, I'll take a stab at it. Feel free to beat me to it ;) |
|
I'm sorry, i looked at the documentation but didn't know where to put this. And tests are broken for me (some repositories doesn't exist anymore ?) Sorry... half of the patch for me, the other for you ? :) (no, sorry, really, i needed it quickly...) |
|
Something like JNRowe/python-github2@feat/page_support. Very small changes:
There should be no functional changes to your version. Hopefully, no problems will arise and this can be merged soon. Update: I was going to collapse my commits too, but I forgot. Bah, I fix that later. |
|
You just rock :) Something funny i just discovered: sometimes, github returns ALL the data instead of just the first page (for list of watching repositories, at least).... "Funny"... :-/ |
I need to play with it some more, but I haven't seen this yet. I was tempted to expose the |
|
@twidi Merged, thanks! The peculiarities of the API's data not withstanding I do feel this is an improvement. |
|
Thanks a lot @JNRowe ! |
For each method asking github for a list, i added a
pageparameter, default to None.The
get_valuesmethod catch this paramter and then create (or update) apost_dataparamter sent tomake_request.There is no easy way with the current code to know how much pages exist for a given list, so it's up to the user to manage the number of pages to retrieve.
In my code i do something like this: