2013-06-16 11:48:23 +02:00
|
|
|
package com.commafeed.backend;
|
|
|
|
|
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
2013-06-18 08:54:53 +02:00
|
|
|
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
2013-06-16 11:48:23 +02:00
|
|
|
|
|
|
|
|
public class DatabaseCleaner {
|
|
|
|
|
|
|
|
|
|
@Inject
|
2013-06-18 08:54:53 +02:00
|
|
|
FeedEntryStatusDAO feedEntryStatusDAO;
|
2013-06-16 11:48:23 +02:00
|
|
|
|
2013-06-18 10:34:11 +02:00
|
|
|
public int cleanOlderThan(long value, TimeUnit unit) {
|
2013-06-16 11:48:23 +02:00
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.add(Calendar.MINUTE, -1 * (int) unit.toMinutes(value));
|
|
|
|
|
|
2013-06-18 10:34:11 +02:00
|
|
|
return feedEntryStatusDAO.delete(cal.getTime());
|
2013-06-16 15:40:33 +02:00
|
|
|
|
2013-06-16 11:48:23 +02:00
|
|
|
}
|
|
|
|
|
}
|