@@ -182,8 +182,30 @@ public class ViolationService {
|
||||
return violations.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
v -> extractGroupKey(v.getPageUrl(), groupBy),
|
||||
Collectors.counting()
|
||||
));
|
||||
Collectors.counting()));
|
||||
}
|
||||
|
||||
public Map<String, Long> getGroupedViolations(List<FileEntity> files, String groupBy, String status,
|
||||
LocalDateTime startDate, LocalDateTime endDate,
|
||||
String sortDirection) {
|
||||
List<Violation> violations;
|
||||
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate");
|
||||
|
||||
if (status != null && !status.isEmpty() && startDate != null && endDate != null) {
|
||||
violations = violationRepository.findByFileEntityInAndStatusAndCreatedDateBetween(files, status, startDate, endDate, sort);
|
||||
} else if (status != null && !status.isEmpty()) {
|
||||
violations = violationRepository.findByFileEntityInAndStatus(files, status, sort);
|
||||
} else if (startDate != null && endDate != null) {
|
||||
violations = violationRepository.findByFileEntityInAndCreatedDateBetween(files, startDate, endDate, sort);
|
||||
} else {
|
||||
violations = violationRepository.findByFileEntityIn(files, sort);
|
||||
}
|
||||
|
||||
return violations.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
v -> extractGroupKey(v.getPageUrl(), groupBy),
|
||||
Collectors.counting()));
|
||||
}
|
||||
|
||||
public ViolationStatisticsResponse getViolationStatistics(Long userId, String fileId,
|
||||
|
||||
Reference in New Issue
Block a user