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 fee02a3

Browse filesBrowse files
committed
Support paging when fetching organization members
Organization members are a paged list in the V3 GitHub API. Previously the code would fetch only the first page of ~30 members and return that. This change switches the return to a PagedIterable<GHUser> so clients can fetch the entire organization's member list.
1 parent ce5ae13 commit fee02a3
Copy full SHA for fee02a3

File tree

Expand file treeCollapse file tree

1 file changed

+8
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-18
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHOrganization.java
+8-18Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,14 @@ public void publicize(GHUser u) throws IOException {
8080
/**
8181
* All the members of this organization.
8282
*/
83-
public List<GHUser> getMembers() throws IOException {
84-
return new AbstractList<GHUser>() {
85-
// these are shallow objects with only some limited values filled out
86-
// TODO: it's better to allow objects to fill themselves in later when missing values are requested
87-
final GHUser[] shallow = root.retrieve().to("/orgs/" + login + "/members", GHUser[].class);
88-
89-
@Override
90-
public GHUser get(int index) {
91-
try {
92-
return root.getUser(shallow[index].getLogin());
93-
} catch (IOException e) {
94-
throw new RuntimeException(e);
95-
}
96-
}
97-
98-
@Override
99-
public int size() {
100-
return shallow.length;
83+
public PagedIterable<GHUser> getMembers() throws IOException {
84+
return new PagedIterable<GHUser>() {
85+
public PagedIterator<GHUser> iterator() {
86+
return new PagedIterator<GHUser>(root.retrieve().asIterator(String.format("/orgs/%s/members", login), GHUser[].class)) {
87+
@Override
88+
protected void wrapUp(GHUser[] page) {
89+
}
90+
};
10191
}
10292
};
10393
}

0 commit comments

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