automatic merging of duplicate feeds

This commit is contained in:
Athou
2013-07-09 08:06:32 +02:00
parent 2e51bb066d
commit 32fb22d503
2 changed files with 28 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.dao.FeedDAO.FeedCount;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.model.Feed;
@@ -40,7 +41,7 @@ public class DatabaseCleaner {
log.info("cleanup done: {} feeds without subscriptions deleted", total);
return total;
}
public long cleanEntriesWithoutFeeds() {
long total = 0;
@@ -69,6 +70,22 @@ public class DatabaseCleaner {
return total;
}
public long cleanDuplicateFeeds() {
long total = 0;
int deleted = -1;
do {
List<FeedCount> fcs = feedDAO.findDuplicates(0, 10, 1);
deleted = fcs.size();
for (FeedCount fc : fcs) {
mergeFeeds(fc.feeds.get(0), fc.feeds);
}
total += deleted;
log.info("merged {} feeds", total);
} while (deleted != 0);
log.info("cleanup done: {} feeds merged", total);
return total;
}
public void mergeFeeds(Feed into, List<Feed> feeds) {
for (Feed feed : feeds) {
if (into.getId().equals(feed.getId())) {