Skip to content

Commit

Permalink
remove schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
ariannazafarana committed Oct 18, 2023
1 parent ba56476 commit d1a0808
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package it.pagopa.interop.signalhub.history.cleanup;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.r2dbc.config.EnableR2dbcAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableR2dbcAuditing
@EnableScheduling
public class SignalHubHistoryCleanupApplication {

public static void main(String[] args) {


SpringApplication.run(SignalHubHistoryCleanupApplication.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.io.Serializable;
import java.time.Instant;


@Getter
@Setter
@Table("SIGNAL")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Repository
public interface SignalRepository extends ReactiveCrudRepository<SignalEntity, Long> {

@Query("delete from signal s where s.tmst_Insert < :date")
@Query("delete from signal s where s.tmst_Insert < :date")
Mono<Void> deleteByDateBefore(LocalDate date );

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package it.pagopa.interop.signalhub.history.cleanup.service;

import reactor.core.publisher.Mono;
import reactor.core.publisher.Signal;

import java.io.FileNotFoundException;
import java.time.LocalDate;

public interface SignalService {

void deleteSignal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;


@Slf4j
@AllArgsConstructor
public class SignalServiceImpl implements SignalService {
Expand All @@ -21,18 +19,14 @@ public class SignalServiceImpl implements SignalService {

@Autowired
private AppConfig appConfig;
@Scheduled(cron = "${pdnd.history-cleanup.scheduled-delay}")
public void deleteSignal() {

String delaydays = appConfig.getDelayDays();
long numeroGiorni = Long.parseLong(delaydays);
LocalDate pastDate = LocalDate.now().minus(numeroGiorni, ChronoUnit.DAYS);
public void deleteSignal() {
LocalDate pastDate = LocalDate.now().minus(Long.parseLong(appConfig.getDelayDays()), ChronoUnit.DAYS);

signalRepository.deleteByDateBefore(pastDate)
.doOnSuccess(x -> log.info("record success"))
.doOnError(x -> log.error("Find an error {}",x.getMessage()))
.subscribe();

}

}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ spring.r2dbc.pool.initial-size=5
spring.r2dbc.pool.enabled=true
spring.data.r2dbc.repositories.enabled=true

pdnd.history-cleanup.scheduled-delay=0 59 */08 * * *
pdnd.history-cleanup.delay-days=30

0 comments on commit d1a0808

Please sign in to comment.