Properly handle pagination in the REST backend#39
Closed
ukleinek wants to merge 5 commits intogetpatchwork:mainfrom
Closed
Properly handle pagination in the REST backend#39ukleinek wants to merge 5 commits intogetpatchwork:mainfrom
ukleinek wants to merge 5 commits intogetpatchwork:mainfrom
Conversation
As a desired side effect this allows to let api.patch_list() return a generator instead of a list.
If there are many patches (or other objects) to be listed, patchwork only returns the first 30 by default. In such a case continue fetching objects using the "next" link provided in the Link: header. Note this changes REST._list() to return a generator instead of a list. All callers only use it to generate a list, so this isn't a problem.
Similar to commit 70f96f9 ("support the delegate filter for REST API") which added the delegate filter this implements an exact match only and not (as promised by `pwclient list -h`) as substring match. But for the same reason as for the delegate filter this is better than ignoring a passed submitter.
This has the advantage that with pagination the first entries are already provided before later entries are queried from the server. Also if the generator isn't walked through completely, only the needed queries are actually executed. All callers of these functions can cope with the returned object being a generator now instead of a list as they just iterate once over it.
Contributor
|
I like your cleanups and would prefer we take this over my PR. I do think that if we are going to depend on requests it may make sense to use it for more than just the one function... But that could always be a future cleanup. |
Contributor
|
@stephenfin Any chance this can get merged? pwclient is pretty useless with the REST backend without this IMO, and some instances don't enable xmlrpc any more. |
Member
|
I have taken all of the fixups from this series, but gone with the pagination implementation from #26 (with a follow-up commit to use a generator). Please let me know if I've missed anything. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on integrating patchwork in my mail setup I noticed that
pwclient listonly lists up to 30 patches. So the motivation for this patch series is commit 7477b4d. The other changes are preparing this or simple cleanups noticed on the way.