SUPPORT-9561: fix scheduler
This commit is contained in:
parent
70b4bdf0c4
commit
5c00196056
2 changed files with 7 additions and 3 deletions
|
|
@ -90,10 +90,10 @@ public class ExcerptHistoryDao {
|
|||
.execute();
|
||||
}
|
||||
|
||||
public void deleteOld() {
|
||||
public void deleteOlderThan(long hours) {
|
||||
dslContext.deleteFrom(EXCERPT_HISTORY)
|
||||
.where(EXCERPT_HISTORY.DATETIME.le(
|
||||
Timestamp.valueOf(LocalDateTime.now().minus(1, ChronoUnit.HOURS))))
|
||||
Timestamp.valueOf(LocalDateTime.now().minus(hours, ChronoUnit.HOURS))))
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ru.micord.ervu.scheduler;
|
||||
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.micord.ervu.dao.ExcerptHistoryDao;
|
||||
|
|
@ -13,6 +14,9 @@ public class ExcerptCleanScheduler {
|
|||
|
||||
private final ExcerptHistoryDao excerptHistoryDao;
|
||||
|
||||
@Value("${excerpt.lifetime.hours:24}")
|
||||
private long fileLifetime;
|
||||
|
||||
public ExcerptCleanScheduler(ExcerptHistoryDao excerptHistoryDao) {
|
||||
this.excerptHistoryDao = excerptHistoryDao;
|
||||
}
|
||||
|
|
@ -20,6 +24,6 @@ public class ExcerptCleanScheduler {
|
|||
@Scheduled(fixedDelayString = "${excerpt.cleanup.delay:30000}")
|
||||
@SchedulerLock(name = "oldExcerptFilesCleaning")
|
||||
public void cleanOld() {
|
||||
excerptHistoryDao.deleteOld();
|
||||
excerptHistoryDao.deleteOlderThan(fileLifetime);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue