use of com.epam.ta.reportportal.ws.model.project.LaunchesPerUser in project service-api by reportportal.
the class GetProjectInfoHandlerImpl method getProjectInfo.
@Override
public ProjectInfoResource getProjectInfo(String projectName, String interval) {
Project project = projectRepository.findByName(normalizeId(projectName)).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
InfoInterval infoInterval = InfoInterval.findByInterval(interval).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, interval));
Filter filter = Filter.builder().withTarget(ProjectInfo.class).withCondition(FilterCondition.builder().eq(CRITERIA_PROJECT_NAME, project.getName()).build()).build();
Page<ProjectInfo> result = projectRepository.findProjectInfoByFilter(filter, Pageable.unpaged());
ProjectInfoResource projectInfoResource = ProjectSettingsConverter.TO_PROJECT_INFO_RESOURCE.apply(result.get().findFirst().orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName)));
LocalDateTime startIntervalDate = getStartIntervalDate(infoInterval);
Map<String, Integer> countPerUser = launchRepository.countLaunchesGroupedByOwner(project.getId(), LaunchModeEnum.DEFAULT.toString(), startIntervalDate);
projectInfoResource.setUniqueTickets(ticketRepository.findUniqueCountByProjectBefore(project.getId(), startIntervalDate));
projectInfoResource.setLaunchesPerUser(countPerUser.entrySet().stream().map(e -> new LaunchesPerUser(e.getKey(), e.getValue())).collect(Collectors.toList()));
if (projectInfoResource.getLaunchesQuantity() != 0) {
formatter.setRoundingMode(RoundingMode.HALF_UP);
double value = projectInfoResource.getLaunchesQuantity() / (infoInterval.getCount() * WEEKS_IN_MONTH);
projectInfoResource.setLaunchesPerWeek(formatter.format(value));
} else {
projectInfoResource.setLaunchesPerWeek(formatter.format(0));
}
return projectInfoResource;
}
Aggregations