Skip to content

Commit

Permalink
Merge pull request #1 from marceloavilaoliveira/develop
Browse files Browse the repository at this point in the history
feat: Process more than 500 SonarQube projects
  • Loading branch information
juaalta authored Jan 24, 2024
2 parents c83cfa5 + 9354a55 commit d20ebd7
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,20 @@ private Measures.ComponentWsResponse getMeasures(WsClient wsClient, Components.C

private List<Components.Component> getProjects(WsClient wsClient) {

return wsClient.components()
.search(new SearchRequest().setQualifiers(Collections.singletonList(Qualifiers.PROJECT)).setPs("500"))
.getComponentsList();
List<Components.Component> projects = new ArrayList<>();
int pageIndex = 1;
boolean hasMore = true;

while (hasMore) {
SearchResponse searchResponse = wsClient.components().search(new SearchRequest()
.setQualifiers(Collections.singletonList(Qualifiers.PROJECT))
.setPs(500)
.setP(pageIndex));
projects.addAll(searchResponse.getComponentsList());
hasMore = searchResponse.getPaging().getPageIndex() * searchResponse.getPaging().getPageSize() < searchResponse.getPaging().getTotal();
pageIndex++;
}

return projects;
}
}

0 comments on commit d20ebd7

Please sign in to comment.