use of org.sonar.server.issue.index.ProjectStatistics in project sonarqube by SonarSource.
the class SearchEventsAction method computeNewIssuesEvents.
private Stream<Event> computeNewIssuesEvents(Map<String, ComponentDto> projectsByUuid, Map<String, BranchDto> branchesByUuids, List<UuidFromPair> uuidFromPairs) {
Map<String, Long> fromsByProjectUuid = uuidFromPairs.stream().collect(Collectors.toMap(UuidFromPair::getComponentUuid, UuidFromPair::getFrom));
List<ProjectStatistics> projectStatistics = issueIndex.searchProjectStatistics(componentUuids(uuidFromPairs), fromDates(uuidFromPairs), userSession.getUuid());
return projectStatistics.stream().map(e -> {
BranchDto branch = branchesByUuids.get(e.getProjectUuid());
ComponentDto project = projectsByUuid.get(branch.getProjectUuid());
long issueCount = e.getIssueCount();
long lastIssueDate = e.getLastIssueDate();
String branchType = branch.getBranchType().equals(PULL_REQUEST) ? "pull request" : "branch";
return Event.newBuilder().setCategory("NEW_ISSUES").setMessage(format("You have %s new %s on project '%s'", issueCount, issueCount == 1 ? "issue" : "issues", project.name()) + (branch.isMain() ? "" : format(" on %s '%s'", branchType, branch.getKey()))).setLink(computeIssuesSearchLink(project, branch, fromsByProjectUuid.get(project.uuid()), userSession.getLogin())).setProject(project.getKey()).setDate(formatDateTime(lastIssueDate)).build();
});
}
Aggregations