Function searchissue() from egit don't return all issues in a GitHub repository

161 views Asked by At

I am trying to find issues from a repository in the GitHub, but when I use the searchissues() function from the IssueService class, that only returns 10 issues. The repository that i am search has more then 40 issues registred.

How can i return all de issues registred in my repository?

public static void main(String[] args) throws IOException {
    GitHubClient client = new GitHubClient();
    client.setCredentials("xxxxxx", "xxxxx");

    int openIssue = 0;
    int closedIssue = 0;


    RepositoryService repositoryService = new RepositoryService(client);
    IRepositoryIdProvider repoId = new repositoryId("purifycss","purifycss");

    IssueService issueService = new IssueService(client);

    for(SearchIssue search : issueService.searchIssues(repoId, "all", " ")){
        System.out.println(search.getTitle() + " " + search.getState() + " " + search.getNumber());

        if(search.getState().equalsIgnoreCase("open"))
            openIssue++;

        if(search.getState().equalsIgnoreCase("closed"))
            closedIssue++;

    }

    System.out.println(openIssue + " " + closedIssue);

}
1

There are 1 answers

0
VonC On BEST ANSWER

That should be related to pagination in GitHub API.

Check out the test org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/live/IssueTest.java #L138-L156: it shows how to iterate over pages of results, instead of the results directly (limited by default)

    IssueService service = new IssueService(client);
    Map<String, String> params = new HashMap<String, String>();
    params.put(IssueService.FILTER_STATE, IssueService.STATE_CLOSED);
    PageIterator<Issue> iterator = service.pageIssues("schacon", "showoff",
            params, 1);
    assertNotNull(iterator);
    assertTrue(iterator.hasNext());
    Collection<Issue> page = iterator.next();
    int pages = iterator.getLastPage();