mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
added feeds cleanup method
This commit is contained in:
@@ -8,16 +8,33 @@ import javax.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryDAO;
|
||||
|
||||
public class DatabaseCleaner {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(DatabaseCleaner.class);
|
||||
|
||||
@Inject
|
||||
FeedDAO feedDAO;
|
||||
|
||||
@Inject
|
||||
FeedEntryDAO feedEntryDAO;
|
||||
|
||||
public long cleanOlderThan(long value, TimeUnit unit) {
|
||||
public long cleanFeedsWithoutSubscriptions() {
|
||||
|
||||
long total = 0;
|
||||
int deleted = -1;
|
||||
do {
|
||||
deleted = feedDAO.deleteWithoutSubscriptions(100);
|
||||
total += deleted;
|
||||
log.info("removed {} feeds without subscriptions", total);
|
||||
} while (deleted != 0);
|
||||
log.info("cleanup done: {} feeds without subscriptions deleted", total);
|
||||
return total;
|
||||
}
|
||||
|
||||
public long cleanEntriesOlderThan(long value, TimeUnit unit) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, -1 * (int) unit.toMinutes(value));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user