mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
actually remove entries for feeds
This commit is contained in:
@@ -41,7 +41,6 @@ public class ScheduledTasks {
|
|||||||
*/
|
*/
|
||||||
@Schedule(hour = "*", persistent = false)
|
@Schedule(hour = "*", persistent = false)
|
||||||
private void cleanFeedsAndContents() {
|
private void cleanFeedsAndContents() {
|
||||||
cleaner.cleanEntriesForFeedsWithoutSubscriptions();
|
|
||||||
cleaner.cleanFeedsWithoutSubscriptions();
|
cleaner.cleanFeedsWithoutSubscriptions();
|
||||||
cleaner.cleanContentsWithoutEntries();
|
cleaner.cleanContentsWithoutEntries();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.commafeed.backend.model.FeedSubscription;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DatabaseCleaningService {
|
public class DatabaseCleaningService {
|
||||||
|
|
||||||
private static final int BATCH_SIZE = 100;
|
private static final int BATCH_SIZE = 100;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -46,36 +46,34 @@ public class DatabaseCleaningService {
|
|||||||
@Inject
|
@Inject
|
||||||
ApplicationSettingsService applicationSettingsService;
|
ApplicationSettingsService applicationSettingsService;
|
||||||
|
|
||||||
public long cleanEntriesForFeedsWithoutSubscriptions() {
|
|
||||||
log.info("cleaning entries for feeds without subscriptions");
|
|
||||||
long total = 0;
|
|
||||||
int deleted = 0;
|
|
||||||
do {
|
|
||||||
deleted = 0;
|
|
||||||
List<Feed> feeds = feedDAO.findWithoutSubscriptions(1);
|
|
||||||
for (Feed feed : feeds) {
|
|
||||||
deleted += feedEntryDAO.delete(feed, BATCH_SIZE);
|
|
||||||
total += deleted;
|
|
||||||
log.info("removed {} entries for feeds without subscriptions", total);
|
|
||||||
}
|
|
||||||
} while (deleted != 0);
|
|
||||||
log.info("cleanup done: {} entries for feeds 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;
|
||||||
|
long totalEntries = 0;
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
do {
|
do {
|
||||||
deleted = feedDAO.delete(feedDAO.findWithoutSubscriptions(1));
|
List<Feed> feeds = feedDAO.findWithoutSubscriptions(1);
|
||||||
|
totalEntries += cleanEntriesForFeedsWithoutSubscriptions(feeds);
|
||||||
|
deleted = feedDAO.delete(feeds);
|
||||||
total += deleted;
|
total += deleted;
|
||||||
log.info("removed {} feeds without subscriptions", total);
|
log.info("removed {} feeds without subscriptions ({} entries)", total, totalEntries);
|
||||||
} while (deleted != 0);
|
} while (deleted != 0);
|
||||||
log.info("cleanup done: {} feeds without subscriptions deleted", total);
|
log.info("cleanup done: {} feeds without subscriptions deleted", total);
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long cleanEntriesForFeedsWithoutSubscriptions(List<Feed> feeds) {
|
||||||
|
long total = 0;
|
||||||
|
for (Feed feed : feeds) {
|
||||||
|
int deleted = 0;
|
||||||
|
do {
|
||||||
|
deleted = feedEntryDAO.delete(feed, BATCH_SIZE);
|
||||||
|
total += deleted;
|
||||||
|
} while (deleted != 0);
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
public long cleanContentsWithoutEntries() {
|
public long cleanContentsWithoutEntries() {
|
||||||
log.info("cleaning contents without entries");
|
log.info("cleaning contents without entries");
|
||||||
long total = 0;
|
long total = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user