mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add setting to delete old entries
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.commafeed.backend.task;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.service.DatabaseCleaningService;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
|
||||
@Singleton
|
||||
public class EntriesExceedingFeedCapacityCleanupTask extends ScheduledTask {
|
||||
|
||||
private final CommaFeedConfiguration config;
|
||||
private final DatabaseCleaningService cleaner;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int maxFeedCapacity = config.getApplicationSettings().getMaxFeedCapacity();
|
||||
if (maxFeedCapacity > 0) {
|
||||
cleaner.cleanEntriesForFeedsExceedingCapacity(maxFeedCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getInitialDelay() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPeriod() {
|
||||
return 60;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeUnit getTimeUnit() {
|
||||
return TimeUnit.MINUTES;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.commafeed.backend.task;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.service.DatabaseCleaningService;
|
||||
|
||||
@@ -18,9 +21,10 @@ public class OldEntriesCleanupTask extends ScheduledTask {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int maxFeedCapacity = config.getApplicationSettings().getMaxFeedCapacity();
|
||||
if (maxFeedCapacity > 0) {
|
||||
cleaner.cleanEntriesForFeedsExceedingCapacity(maxFeedCapacity);
|
||||
int maxAgeDays = config.getApplicationSettings().getMaxEntriesAgeDays();
|
||||
if (maxAgeDays > 0) {
|
||||
Date threshold = DateUtils.addDays(new Date(), -1 * maxAgeDays);
|
||||
cleaner.cleanEntriesOlderThan(threshold);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class OldStatusesCleanupTask extends ScheduledTask {
|
||||
|
||||
@Override
|
||||
public long getInitialDelay() {
|
||||
return 10;
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ public class OrphanedContentsCleanupTask extends ScheduledTask {
|
||||
|
||||
@Override
|
||||
public long getInitialDelay() {
|
||||
return 20;
|
||||
return 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ public class OrphanedFeedsCleanupTask extends ScheduledTask {
|
||||
|
||||
@Override
|
||||
public long getInitialDelay() {
|
||||
return 15;
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user