Skip to content

Commit

Permalink
feat: add logging & retention property
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaDel03 committed Oct 4, 2024
1 parent 771d7cd commit 1b3eb74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import it.finanze.sanita.fse2.ms.gtw.garbage.repository.entity.AuditIniETY;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
Expand All @@ -21,9 +22,12 @@ public class AuditIniRetentionRepo implements IAuditIniRetentionRepo {
@Autowired
private MongoTemplate mongoTemplate;

@Value("${retention.transactions-query.limit}")
private Integer retentionQueryLimit;

@Override
public void deleteExpiredAudit(Date date) {
Pageable pageable = PageRequest.of(0, 100);
Pageable pageable = PageRequest.of(0, retentionQueryLimit);
Query query = new Query(Criteria.where(AuditIniETY.EXPIRING_DATE).lte(date)).with(pageable);

List<AuditIniETY> audits;
Expand All @@ -42,11 +46,11 @@ public void deleteExpiredAudit(Date date) {
pageable = pageable.next();
query.with(pageable);

log.debug("{} records has been deleted in the current batch", deletedInBatch);
log.info("{} records has been deleted in the current batch", deletedInBatch);

} while (!audits.isEmpty());

log.debug("Total records deleted: {}", totalDeleted);
log.info("Total records deleted: {}", totalDeleted);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void action() {
public void run() {
log.debug("Audit-ini Retention Scheduler - Retention Scheduler starting");
try {
log.debug("Checking for expired ini audit...");
log.info("Checking for expired ini audit...");
auditIniRetentionSRV.deleteAudit(new Date());
} catch (Exception e) {
log.warn("Audit-ini Scheduler - Error while executing audit-ini data retention", e);
Expand Down

0 comments on commit 1b3eb74

Please sign in to comment.