Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f52b4a2

Browse filesBrowse files
committed
Allows to define page size for repository lists.
Extension of the listRepositories() with the desired pageSize. This allows to reduce the number of calls to GitHub API for fetching the entire set of repositories browsing all the pages. Additionally allows to match the UX paging with the underlying GitHub API paging, increasing performance and reducing hourly API allowance.
1 parent c96e6c7 commit f52b4a2
Copy full SHA for f52b4a2

File tree

Expand file treeCollapse file tree

1 file changed

+13
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-2
lines changed

‎src/main/java/org/kohsuke/github/GHPerson.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHPerson.java
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,25 @@ public synchronized Map<String,GHRepository> getRepositories() throws IOExceptio
5555
}
5656

5757
/**
58-
* Lists up all the repositories.
58+
* Lists up all the repositories using a 30 items page size.
5959
*
6060
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
6161
*/
6262
public PagedIterable<GHRepository> listRepositories() {
63+
return listRepositories(30);
64+
}
65+
66+
/**
67+
* Lists up all the repositories using the specified page size.
68+
*
69+
* @param pageSize size for each page of items returned by GitHub. Maximum page size is 100.
70+
*
71+
* Unlike {@link #getRepositories()}, this does not wait until all the repositories are returned.
72+
*/
73+
public PagedIterable<GHRepository> listRepositories(final int pageSize) {
6374
return new PagedIterable<GHRepository>() {
6475
public PagedIterator<GHRepository> iterator() {
65-
return new PagedIterator<GHRepository>(root.retrieve().asIterator("/users/" + login + "/repos", GHRepository[].class)) {
76+
return new PagedIterator<GHRepository>(root.retrieve().asIterator("/users/" + login + "/repos?per_page=" + pageSize, GHRepository[].class)) {
6677
@Override
6778
protected void wrapUp(GHRepository[] page) {
6879
for (GHRepository c : page)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.