let hibernate clean entries

This commit is contained in:
Athou
2014-08-15 15:09:48 +02:00
parent e96cbcb057
commit 823cb03f9b
3 changed files with 2 additions and 23 deletions

View File

@@ -16,7 +16,6 @@ import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.dao.UnitOfWork;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
/**
@@ -35,25 +34,6 @@ public class DatabaseCleaningService {
private final FeedEntryContentDAO feedEntryContentDAO;
private final FeedEntryStatusDAO feedEntryStatusDAO;
public long cleanEntriesWithoutSubscriptions() {
log.info("cleaning entries without subscriptions");
long total = 0;
int deleted = 0;
do {
deleted = new UnitOfWork<Integer>(sessionFactory) {
@Override
protected Integer runInSession() throws Exception {
List<FeedEntry> entries = feedEntryDAO.findWithoutSubscriptions(BATCH_SIZE);
return feedEntryDAO.delete(entries);
}
}.run();
total += deleted;
log.info("removed {} entries without subscriptions", total);
} while (deleted != 0);
log.info("cleanup done: {} entries without subscriptions deleted", total);
return total;
}
public long cleanFeedsWithoutSubscriptions() {
log.info("cleaning feeds without subscriptions");
long total = 0;

View File

@@ -25,7 +25,7 @@ public class OldStatusesCleanupTask implements ScheduledTask {
@Override
public long getInitialDelay() {
return 5;
return 10;
}
@Override

View File

@@ -14,14 +14,13 @@ public class OrphansCleanupTask implements ScheduledTask {
@Override
public void run() {
cleaner.cleanEntriesWithoutSubscriptions();
cleaner.cleanFeedsWithoutSubscriptions();
cleaner.cleanContentsWithoutEntries();
}
@Override
public long getInitialDelay() {
return 30;
return 5;
}
@Override