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,19 +89,17 @@ 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) {
|
||||||
activeFilesUploadedBytes += add.getFileSize();
|
activeFilesUploadedBytes += add.getFileSize();
|
||||||
|
|
||||||
if(add.getAdded().toInstant().isAfter(licenseReportRequest.getStartDate())) {
|
if (add.getAdded().toInstant().isAfter(licenseReportRequest.getStartDate())) {
|
||||||
|
|
||||||
numberOfAnalyzedPages += add.getNumberOfPages();
|
numberOfAnalyzedPages += add.getNumberOfPages();
|
||||||
currentMonthNumberOfAnalyzedPages += add.getNumberOfPages();
|
currentMonthNumberOfAnalyzedPages += add.getNumberOfPages();
|
||||||
@ -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) {
|
||||||
@ -133,7 +144,7 @@ public class LicenseReportService {
|
|||||||
if (ocrFilesInMonth != null) {
|
if (ocrFilesInMonth != null) {
|
||||||
for (var ocrFile : ocrFilesInMonth) {
|
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.
|
numberOfOcrPages += ocrFile.getNumberOfPages(); // We count the entire document if ocr is performed.
|
||||||
currentMonthNumberOfOcrPages += ocrFile.getNumberOfPages();
|
currentMonthNumberOfOcrPages += ocrFile.getNumberOfPages();
|
||||||
numberOfOcrFiles++;
|
numberOfOcrFiles++;
|
||||||
@ -180,5 +191,4 @@ public class LicenseReportService {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user