Skip to content

Commit

Permalink
GRAD2-2817
Browse files Browse the repository at this point in the history
Fix for duplicated archive school reports
  • Loading branch information
arybakov-cgi committed Sep 6, 2024
1 parent 8287313 commit 87bdd7c
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -892,19 +892,18 @@ public Integer archiveSchoolReports(long batchId, List<String> schoolOfRecords,
Integer updatedReportsCount = 0;
Integer deletedReportsCount = 0;
Integer originalReportsCount = 0;
reportType = StringUtils.upperCase(StringUtils.endsWithIgnoreCase(reportType, "ARC") ? StringUtils.removeEndIgnoreCase(reportType, "ARC") : reportType);
String archivedReportType = StringUtils.upperCase(StringUtils.endsWith(reportType, "ARC") ? reportType : reportType + "ARC");
if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) {
originalReportsCount += schoolReportsRepository.countBySchoolOfRecordsAndReportType(schoolOfRecords, reportType);
updatedReportsCount += schoolReportsRepository.archiveSchoolReports(schoolOfRecords, reportType, archivedReportType, batchId);
if(originalReportsCount.equals(updatedReportsCount)) {
if(updatedReportsCount > 0 && originalReportsCount.equals(updatedReportsCount)) {
deletedReportsCount += schoolReportsRepository.deleteSchoolReports(schoolOfRecords, archivedReportType);
logger.debug("{} School Reports deleted", deletedReportsCount);
}
} else {
originalReportsCount += schoolReportsRepository.countByReportType(reportType);
updatedReportsCount += schoolReportsRepository.archiveSchoolReports(reportType, archivedReportType, batchId);
if(originalReportsCount.equals(updatedReportsCount)) {
if(updatedReportsCount > 0 && originalReportsCount.equals(updatedReportsCount)) {
deletedReportsCount += schoolReportsRepository.deleteSchoolReports(archivedReportType);
logger.debug("{} School Reports deleted", deletedReportsCount);
}
Expand Down

0 comments on commit 87bdd7c

Please sign in to comment.