github-api
github-api copied to clipboard
Document reading pages of items
Return open or closed issues in pagination
public List<GHIssue> getIssues(GHIssueState state) throws IOException {
return this.listIssues(state).toList();
}
public List<GHIssue> getIssues(GHIssueState state, GHMilestone milestone) throws IOException {
Requester requester = (Requester)((Requester)this.root.createRequest().with("state", state)).with("milestone", milestone == null ? "none" : "" + milestone.getNumber());
return ((Requester)requester.withUrlPath(this.getApiTailUrl("issues"), new String[0])).toIterable(GHIssue[].class, (item) -> {
item.wrap(this);
}).toList();
}
I didn’t see any support for paging
Need to manually specify page and pre_page
Pagination is built into the library using PagedIterable
. getIssues()
will automatically traverse all pages to get a list.
Have you looked at this?
https://github.com/hub4j/github-api/blob/3a11b7ccbf5ef80e6231c15b539c5d386f827caf/src/main/java/org/kohsuke/github/GHRepository.java#L425-L430
That will allow you to set page size as well.
HI @bitwiseman
I know that there is automatic traversal of all pages, but I need a page that can be divided according to parameters, because our above sometimes produces tens of thousands of issues, if automatic page traversal takes a lot of time.
@eric-5512
Do you mean you want to start at a specific page? Or that you want to set the page size before you start iterating? Or that you want support for getting a single page of your choice?
What would you like to be able to do that you cannot currently do? If you can provide a sample of what you'd like your code to look like that would help with understanding your reuqest.
HI @bitwiseman
Only one page of information is displayed at a time, and then how many pieces of data can be displayed on one page.
When I select the second page, I re-request the data of the second page.
For example, the first page https://api.github.com/user/repos?page=1&per_page=25
Call https://api.github.com/user/repos?page=2&per_page=25 when I click on the second page
@eric-5512 I'm sorry, I'm still not understanding.
GHIssueState state;
List<GHIssue> page;
PagedIterator<GHIssue> iterator = listIssues(state).withPageSize(20).iterator()
while (iterator.hasNext()) {
page = iterator. nextPage();
}
https://github.com/hub4j/github-api/blob/3a11b7ccbf5ef80e6231c15b539c5d386f827caf/src/main/java/org/kohsuke/github/PagedIterator.java#L120
If you're talking about paging forward and back or selecting a specific page, see #348.
HI @bitwiseman
Ok let me see, thanks
@eric-5512 Any update?
I'm going to leave this open as a documentation issue. It would be helpful to have a doc that covers this behavior.