mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
database agnostic cleanup query
This commit is contained in:
@@ -12,11 +12,16 @@ public class DatabaseCleaner {
|
||||
@Inject
|
||||
FeedEntryStatusDAO feedEntryStatusDAO;
|
||||
|
||||
public int cleanOlderThan(long value, TimeUnit unit) {
|
||||
public long cleanOlderThan(long value, TimeUnit unit) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, -1 * (int) unit.toMinutes(value));
|
||||
|
||||
return feedEntryStatusDAO.delete(cal.getTime());
|
||||
|
||||
long total = 0;
|
||||
int deleted = -1;
|
||||
do {
|
||||
deleted = feedEntryStatusDAO.delete(cal.getTime(), 100);
|
||||
total += deleted;
|
||||
} while (deleted != 0);
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user