RED-6543: Fixed QA findings in license report #21
@ -35,6 +35,11 @@ public class LicenseReportService {
|
|||||||
public LicenseReport getLicenseReport(LicenseReportRequest licenseReportRequest) {
|
public LicenseReport getLicenseReport(LicenseReportRequest licenseReportRequest) {
|
||||||
|
|
||||||
var files = fileStatusService.getStatusesAddedBefore(OffsetDateTime.ofInstant(licenseReportRequest.getEndDate(), UTC_ZONE_ID));
|
var files = fileStatusService.getStatusesAddedBefore(OffsetDateTime.ofInstant(licenseReportRequest.getEndDate(), UTC_ZONE_ID));
|
||||||
|
|
||||||
|
if (files == null || files.isEmpty()) {
|
||||||
|
return LicenseReport.builder().startDate(licenseReportRequest.getStartDate()).endDate(licenseReportRequest.getEndDate()).build();
|
||||||
|
}
|
||||||
|
|
||||||
files.sort(Comparator.comparing(FileModel::getAdded));
|
files.sort(Comparator.comparing(FileModel::getAdded));
|
||||||
|
|
||||||
var addDossiers = dossierService.getAllDossiers();
|
var addDossiers = dossierService.getAllDossiers();
|
||||||
@ -56,7 +61,10 @@ public class LicenseReportService {
|
|||||||
if (file.getHardDeletedTime() != null && file.getHardDeletedTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
if (file.getHardDeletedTime() != null && file.getHardDeletedTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
||||||
hardDeletes.computeIfAbsent(YearMonth.from(file.getHardDeletedTime()), entry -> new ArrayList<>()).add(file);
|
hardDeletes.computeIfAbsent(YearMonth.from(file.getHardDeletedTime()), entry -> new ArrayList<>()).add(file);
|
||||||
}
|
}
|
||||||
if (dossiersById.get(file.getDossierId()).getArchivedTime() != null && dossiersById.get(file.getDossierId()).getArchivedTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
if (dossiersById.get(file.getDossierId()).getArchivedTime() != null && dossiersById.get(file.getDossierId())
|
||||||
|
.getArchivedTime()
|
||||||
|
.toInstant()
|
||||||
|
.isBefore(licenseReportRequest.getEndDate())) {
|
||||||
archives.computeIfAbsent(YearMonth.from(dossiersById.get(file.getDossierId()).getArchivedTime()), entry -> new ArrayList<>()).add(file);
|
archives.computeIfAbsent(YearMonth.from(dossiersById.get(file.getDossierId()).getArchivedTime()), entry -> new ArrayList<>()).add(file);
|
||||||
}
|
}
|
||||||
if (file.getOcrStartTime() != null && file.getOcrStartTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
if (file.getOcrStartTime() != null && file.getOcrStartTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
||||||
@ -81,13 +89,11 @@ public class LicenseReportService {
|
|||||||
int numberOfAnalyzedFiles = 0;
|
int numberOfAnalyzedFiles = 0;
|
||||||
int numberOfOcrFiles = 0;
|
int numberOfOcrFiles = 0;
|
||||||
|
|
||||||
|
|
||||||
while (!currentMonth.isAfter(endMonth)) {
|
while (!currentMonth.isAfter(endMonth)) {
|
||||||
|
|
||||||
int currentMonthNumberOfAnalyzedPages = 0;
|
int currentMonthNumberOfAnalyzedPages = 0;
|
||||||
int currentMonthNumberOfOcrPages = 0;
|
int currentMonthNumberOfOcrPages = 0;
|
||||||
|
|
||||||
|
|
||||||
var addedFilesInMonth = adds.get(currentMonth);
|
var addedFilesInMonth = adds.get(currentMonth);
|
||||||
if (addedFilesInMonth != null) {
|
if (addedFilesInMonth != null) {
|
||||||
for (var add : addedFilesInMonth) {
|
for (var add : addedFilesInMonth) {
|
||||||
@ -105,10 +111,15 @@ public class LicenseReportService {
|
|||||||
var softDeletedFilesInMonth = softDeletes.get(currentMonth);
|
var softDeletedFilesInMonth = softDeletes.get(currentMonth);
|
||||||
if (softDeletedFilesInMonth != null) {
|
if (softDeletedFilesInMonth != null) {
|
||||||
for (var softDeleted : softDeletedFilesInMonth) {
|
for (var softDeleted : softDeletedFilesInMonth) {
|
||||||
|
if (dossiersById.get(softDeleted.getDossierId()).getArchivedTime() != null) {
|
||||||
|
archivedFilesUploadedBytes -= softDeleted.getFileSize();
|
||||||
|
trashFilesUploadedBytes += softDeleted.getFileSize();
|
||||||
|
} else {
|
||||||
activeFilesUploadedBytes -= softDeleted.getFileSize();
|
activeFilesUploadedBytes -= softDeleted.getFileSize();
|
||||||
trashFilesUploadedBytes += softDeleted.getFileSize();
|
trashFilesUploadedBytes += softDeleted.getFileSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var archivedFilesInMonth = archives.get(currentMonth);
|
var archivedFilesInMonth = archives.get(currentMonth);
|
||||||
if (archivedFilesInMonth != null) {
|
if (archivedFilesInMonth != null) {
|
||||||
@ -180,5 +191,4 @@ public class LicenseReportService {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user