RED-6543: Fixed QA findings in license report #21
@ -35,6 +35,11 @@ public class LicenseReportService {
|
||||
public LicenseReport getLicenseReport(LicenseReportRequest licenseReportRequest) {
|
||||
|
||||
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));
|
||||
|
||||
var addDossiers = dossierService.getAllDossiers();
|
||||
@ -56,7 +61,10 @@ public class LicenseReportService {
|
||||
if (file.getHardDeletedTime() != null && file.getHardDeletedTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
||||
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);
|
||||
}
|
||||
if (file.getOcrStartTime() != null && file.getOcrStartTime().toInstant().isBefore(licenseReportRequest.getEndDate())) {
|
||||
@ -81,19 +89,17 @@ public class LicenseReportService {
|
||||
int numberOfAnalyzedFiles = 0;
|
||||
int numberOfOcrFiles = 0;
|
||||
|
||||
|
||||
while (!currentMonth.isAfter(endMonth)) {
|
||||
|
||||
int currentMonthNumberOfAnalyzedPages = 0;
|
||||
int currentMonthNumberOfOcrPages = 0;
|
||||
|
||||
|
||||
var addedFilesInMonth = adds.get(currentMonth);
|
||||
if (addedFilesInMonth != null) {
|
||||
for (var add : addedFilesInMonth) {
|
||||
activeFilesUploadedBytes += add.getFileSize();
|
||||
|
||||
if(add.getAdded().toInstant().isAfter(licenseReportRequest.getStartDate())) {
|
||||
if (add.getAdded().toInstant().isAfter(licenseReportRequest.getStartDate())) {
|
||||
|
||||
numberOfAnalyzedPages += add.getNumberOfPages();
|
||||
currentMonthNumberOfAnalyzedPages += add.getNumberOfPages();
|
||||
@ -105,8 +111,13 @@ public class LicenseReportService {
|
||||
var softDeletedFilesInMonth = softDeletes.get(currentMonth);
|
||||
if (softDeletedFilesInMonth != null) {
|
||||
for (var softDeleted : softDeletedFilesInMonth) {
|
||||
activeFilesUploadedBytes -= softDeleted.getFileSize();
|
||||
trashFilesUploadedBytes += softDeleted.getFileSize();
|
||||
if (dossiersById.get(softDeleted.getDossierId()).getArchivedTime() != null) {
|
||||
archivedFilesUploadedBytes -= softDeleted.getFileSize();
|
||||
trashFilesUploadedBytes += softDeleted.getFileSize();
|
||||
} else {
|
||||
activeFilesUploadedBytes -= softDeleted.getFileSize();
|
||||
trashFilesUploadedBytes += softDeleted.getFileSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +144,7 @@ public class LicenseReportService {
|
||||
if (ocrFilesInMonth != null) {
|
||||
for (var ocrFile : ocrFilesInMonth) {
|
||||
|
||||
if(ocrFile.getOcrStartTime().toInstant().isAfter(licenseReportRequest.getStartDate())) {
|
||||
if (ocrFile.getOcrStartTime().toInstant().isAfter(licenseReportRequest.getStartDate())) {
|
||||
numberOfOcrPages += ocrFile.getNumberOfPages(); // We count the entire document if ocr is performed.
|
||||
currentMonthNumberOfOcrPages += ocrFile.getNumberOfPages();
|
||||
numberOfOcrFiles++;
|
||||
@ -146,8 +157,8 @@ public class LicenseReportService {
|
||||
var monthEndDate = currentMonth.atEndOfMonth().atTime(23, 59).atZone(UTC_ZONE_ID).toInstant();
|
||||
|
||||
monthlyData.add(MonthlyReportData.builder()
|
||||
.startDate(currentMonth.atDay(1).atStartOfDay(UTC_ZONE_ID).toInstant())
|
||||
.endDate(monthEndDate.isBefore(licenseReportRequest.getEndDate()) ? monthEndDate : licenseReportRequest.getEndDate())
|
||||
.startDate(currentMonth.atDay(1).atStartOfDay(UTC_ZONE_ID).toInstant())
|
||||
.endDate(monthEndDate.isBefore(licenseReportRequest.getEndDate()) ? monthEndDate : licenseReportRequest.getEndDate())
|
||||
.activeFilesUploadedBytes(activeFilesUploadedBytes)
|
||||
.trashFilesUploadedBytes(trashFilesUploadedBytes)
|
||||
.archivedFilesUploadedBytes(archivedFilesUploadedBytes)
|
||||
@ -180,5 +191,4 @@ public class LicenseReportService {
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user