From a166c5b205473253f1b8a5b62d2d02fbe9a239c4 Mon Sep 17 00:00:00 2001 From: "DIR\\noemi.luongo" Date: Wed, 29 Nov 2023 10:15:20 +0100 Subject: [PATCH] fix date in UTC --- .../history/cleanup/repository/SignalRepository.java | 3 ++- .../history/cleanup/service/impl/SignalServiceImpl.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/pagopa/interop/signalhub/history/cleanup/repository/SignalRepository.java b/src/main/java/it/pagopa/interop/signalhub/history/cleanup/repository/SignalRepository.java index 9519e7e..9ed5976 100644 --- a/src/main/java/it/pagopa/interop/signalhub/history/cleanup/repository/SignalRepository.java +++ b/src/main/java/it/pagopa/interop/signalhub/history/cleanup/repository/SignalRepository.java @@ -6,12 +6,13 @@ import org.springframework.stereotype.Repository; import reactor.core.publisher.Mono; +import java.time.Instant; import java.time.LocalDate; @Repository public interface SignalRepository extends ReactiveCrudRepository { @Query("delete from SIGNAL where tmst_Insert < :date") - Mono deleteByDate(LocalDate date ); + Mono deleteByDate(Instant date ); } \ No newline at end of file diff --git a/src/main/java/it/pagopa/interop/signalhub/history/cleanup/service/impl/SignalServiceImpl.java b/src/main/java/it/pagopa/interop/signalhub/history/cleanup/service/impl/SignalServiceImpl.java index 6e91d7a..33a75fe 100644 --- a/src/main/java/it/pagopa/interop/signalhub/history/cleanup/service/impl/SignalServiceImpl.java +++ b/src/main/java/it/pagopa/interop/signalhub/history/cleanup/service/impl/SignalServiceImpl.java @@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.Instant; import java.time.LocalDate; import java.time.temporal.ChronoUnit; @@ -23,10 +24,10 @@ public class SignalServiceImpl implements SignalService { private AppConfig appConfig; public void cleanSignal() { - LocalDate pastDate = LocalDate.now().minus(Long.parseLong(appConfig.getDelayDays()), ChronoUnit.DAYS); + Instant pastDate = Instant.now().minus(Long.parseLong(appConfig.getDelayDays()), ChronoUnit.DAYS); signalRepository.deleteByDate(pastDate) .doOnSuccess(x -> log.info("clean complete with success")) - .doOnError(ex -> log.error("Find an error {}",ex)) + .doOnError(ex -> log.error("Error on signal cleanup {}",ex)) .subscribe(); }