dev add violation notion
Test Workflow / test (push) Successful in 4s

This commit is contained in:
vladp
2026-03-18 17:55:14 +07:00
parent 02b8d3ee6d
commit c7660c30de
3 changed files with 38 additions and 3 deletions
@@ -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,