mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
let hibernate clean entries
This commit is contained in:
@@ -16,7 +16,6 @@ import com.commafeed.backend.dao.FeedEntryDAO;
|
|||||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||||
import com.commafeed.backend.dao.UnitOfWork;
|
import com.commafeed.backend.dao.UnitOfWork;
|
||||||
import com.commafeed.backend.model.Feed;
|
import com.commafeed.backend.model.Feed;
|
||||||
import com.commafeed.backend.model.FeedEntry;
|
|
||||||
import com.commafeed.backend.model.FeedEntryStatus;
|
import com.commafeed.backend.model.FeedEntryStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,25 +34,6 @@ public class DatabaseCleaningService {
|
|||||||
private final FeedEntryContentDAO feedEntryContentDAO;
|
private final FeedEntryContentDAO feedEntryContentDAO;
|
||||||
private final FeedEntryStatusDAO feedEntryStatusDAO;
|
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() {
|
public long cleanFeedsWithoutSubscriptions() {
|
||||||
log.info("cleaning feeds without subscriptions");
|
log.info("cleaning feeds without subscriptions");
|
||||||
long total = 0;
|
long total = 0;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class OldStatusesCleanupTask implements ScheduledTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getInitialDelay() {
|
public long getInitialDelay() {
|
||||||
return 5;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ public class OrphansCleanupTask implements ScheduledTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
cleaner.cleanEntriesWithoutSubscriptions();
|
|
||||||
cleaner.cleanFeedsWithoutSubscriptions();
|
cleaner.cleanFeedsWithoutSubscriptions();
|
||||||
cleaner.cleanContentsWithoutEntries();
|
cleaner.cleanContentsWithoutEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getInitialDelay() {
|
public long getInitialDelay() {
|
||||||
return 30;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user