@Override public Integer getPullRequestCount( Repository repository, PullRequestState[] states, PullRequestFilter[] filters) { final PullRequestPage page = this.pageRetriever.getPullRequestPage(repository, states, 1); final Counter<Integer> counter = new Counter.IntegerImpl(); try { counter.increment(this.pageProcessor.processPullRequestPage(page, filters)); } catch (FilteredException ex) { counter.increment(page.getTotal()); } counter.increment( this.getCountForPageRange( repository, states, filters, 2, (int) Math.ceil(page.getTotal() / page.getPageLen()))); return counter.getTotal(); }
protected Integer getCountForPageRange( Repository repository, PullRequestState[] states, PullRequestFilter[] filters, int startPage, int totalPages) { Counter<Integer> counter = new Counter.IntegerImpl(); for (int i = startPage; i <= totalPages; i++) { PullRequestPage page = this.pageRetriever.getPullRequestPage(repository, states, i); try { counter.increment(this.pageProcessor.processPullRequestPage(page, filters)); } catch (IntegerSummingFilterFailedException ex) { counter.increment(ex.getTotal()); break; } catch (FilteredException ex) { break; } } return counter.getTotal(); }