@@ -129,8 +129,7 @@ public class ViolationHandler implements RequestHandler {
|
||||
}
|
||||
|
||||
for (Violation violation : content) {
|
||||
if (violation.getStatus().equals(ViolationStatus.NOT_OWNER_FILE.name()) ||
|
||||
firstShowViolation != null && Objects.equals(firstShowViolation.getId(), violation.getId())) continue;
|
||||
if (firstShowViolation != null && Objects.equals(firstShowViolation.getId(), violation.getId())) continue;
|
||||
|
||||
ViolationResponse.ViolationDto violationDto = ViolationResponse.ViolationDto.fromEntity(violation);
|
||||
violationDto.setCountry(geoCountryService.getCountryName(violation.getPageUrl()));
|
||||
|
||||
@@ -58,6 +58,15 @@ public interface ViolationRepository extends JpaRepository<Violation, Long> {
|
||||
LocalDateTime startDate,
|
||||
LocalDateTime endDate);
|
||||
|
||||
Page<Violation> findByFileEntityInAndStatusNot(List<FileEntity> files, String excludeStatus, Pageable pageable);
|
||||
|
||||
Page<Violation> findByFileEntityInAndStatusNotAndStatus(List<FileEntity> files, String excludeStatus,
|
||||
String includeStatus, Pageable pageable);
|
||||
|
||||
Page<Violation> findByFileEntityInAndStatusNotAndCreatedDateBetween(List<FileEntity> files, String excludeStatus,
|
||||
LocalDateTime startDate, LocalDateTime endDate,
|
||||
Pageable pageable);
|
||||
|
||||
@Query("SELECT COUNT(v) FROM Violation v WHERE v.fileEntity.id IN :fileIds")
|
||||
long countByFileEntityIdIn(@Param("fileIds") List<String> fileIds);
|
||||
|
||||
|
||||
@@ -106,22 +106,29 @@ public class ViolationService {
|
||||
}
|
||||
|
||||
public Page<Violation> getViolationsByFiles(List<FileEntity> files, int page, int size, String sortDirection) {
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate");
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC,
|
||||
"createdDate");
|
||||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
return violationRepository.findByFileEntityIn(files, pageable);
|
||||
|
||||
return violationRepository.findByFileEntityInAndStatusNot(files, ViolationStatus.NOT_OWNER_FILE.name(), pageable);
|
||||
}
|
||||
|
||||
public Page<Violation> getViolationsByFilesAndStatus(List<FileEntity> files, String status, int page, int size, String sortDirection) {
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate");
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC,
|
||||
"createdDate");
|
||||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
|
||||
return violationRepository.findByFileEntityInAndStatus(files, status, pageable);
|
||||
}
|
||||
|
||||
public Page<Violation> getViolationsByFilesAndDateRange(List<FileEntity> files, LocalDateTime startDate, LocalDateTime endDate,
|
||||
int page, int size, String sortDirection) {
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate");
|
||||
Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC,
|
||||
"createdDate");
|
||||
Pageable pageable = PageRequest.of(page, size, sort);
|
||||
return violationRepository.findByFileEntityInAndCreatedDateBetween(files, startDate, endDate, pageable);
|
||||
|
||||
return violationRepository.findByFileEntityInAndStatusNotAndCreatedDateBetween(files,
|
||||
ViolationStatus.NOT_OWNER_FILE.name(), startDate, endDate, pageable);
|
||||
}
|
||||
|
||||
public Map<String, Long> getGroupedViolations(List<FileEntity> files, String groupBy, String status,
|
||||
|
||||
Reference in New Issue
Block a user