Skip to content

Refactor pagination #2099

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/org/kohsuke/github/GHAppInstallation.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public PagedSearchIterable<GHRepository> listRepositories() {

request = root().createRequest().withUrlPath("/installation/repositories").build();

return new PagedSearchIterable<>(root(), request, GHAppInstallationRepositoryResult.class);
return new PagedSearchIterable<>(new PaginatedEndpoint<>(root()
.getClient(), request, GHAppInstallationRepositoryResult.class, GHRepository.class, null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
public class GHAppInstallationRequest extends GHObject {
private GHOrganization account;

private GHUser requester;

/**
Expand Down
66 changes: 0 additions & 66 deletions src/main/java/org/kohsuke/github/GHAppInstallationsIterable.java

This file was deleted.

7 changes: 6 additions & 1 deletion src/main/java/org/kohsuke/github/GHAppInstallationsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
/**
* Represents the one page of GHAppInstallations.
*/
class GHAppInstallationsPage {
class GHAppInstallationsPage implements GitHubPage<GHAppInstallation> {
private GHAppInstallation[] installations;
private int totalCount;

@Override
public GHAppInstallation[] getItems() {
return getInstallations();
}

/**
* Gets the total count.
*
Expand Down
67 changes: 0 additions & 67 deletions src/main/java/org/kohsuke/github/GHArtifactsIterable.java

This file was deleted.

21 changes: 6 additions & 15 deletions src/main/java/org/kohsuke/github/GHArtifactsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
class GHArtifactsPage {
class GHArtifactsPage implements GitHubPage<GHArtifact> {
private GHArtifact[] artifacts;
private int totalCount;

@Override
public GHArtifact[] getItems() {
return artifacts;
}

/**
* Gets the total count.
*
Expand All @@ -20,18 +25,4 @@ class GHArtifactsPage {
public int getTotalCount() {
return totalCount;
}

/**
* Gets the artifacts.
*
* @param owner
* the owner
* @return the artifacts
*/
GHArtifact[] getArtifacts(GHRepository owner) {
for (GHArtifact artifact : artifacts) {
artifact.wrapUp(owner);
}
return artifacts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public PagedSearchIterable<GHRepository> listRepositories() {

request = root().createRequest().withUrlPath("/installation/repositories").build();

return new PagedSearchIterable<>(root(), request, GHAuthenticatedAppInstallationRepositoryResult.class);
return new PagedSearchIterable<>(new PaginatedEndpoint<>(root()
.getClient(), request, GHAuthenticatedAppInstallationRepositoryResult.class, GHRepository.class, null));
}

}
67 changes: 0 additions & 67 deletions src/main/java/org/kohsuke/github/GHCheckRunsIterable.java

This file was deleted.

21 changes: 6 additions & 15 deletions src/main/java/org/kohsuke/github/GHCheckRunsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
class GHCheckRunsPage {
class GHCheckRunsPage implements GitHubPage<GHCheckRun> {
private GHCheckRun[] checkRuns;
private int totalCount;

@Override
public GHCheckRun[] getItems() {
return checkRuns;
}

/**
* Gets the total count.
*
Expand All @@ -20,18 +25,4 @@ class GHCheckRunsPage {
public int getTotalCount() {
return totalCount;
}

/**
* Gets the check runs.
*
* @param owner
* the owner
* @return the check runs
*/
GHCheckRun[] getCheckRuns(GHRepository owner) {
for (GHCheckRun checkRun : checkRuns) {
checkRun.wrap(owner);
}
return checkRuns;
}
}
Loading
Loading