# HG changeset patch # User dirk # Date 1338604204 -7200 # Node ID f74fe7cb5091098f8afe8fdbe147ca2591b10767 # Parent adf7f617bda9edc71f3a4433bc790fadc5a9215f when updating feeds, only ever create new Feed objects for entries that are younger than the current expire date. This ensures that we do not see old, read, expired entries again diff -r adf7f617bda9 -r f74fe7cb5091 backend/AbstractBackend.py --- a/backend/AbstractBackend.py Sat Jun 02 04:24:49 2012 +0200 +++ b/backend/AbstractBackend.py Sat Jun 02 04:30:04 2012 +0200 @@ -1,6 +1,12 @@ from datetime import datetime, timedelta +def calculateExpireDate(preferences): + now = datetime.now() + daysToKeepFeedEntries = preferences.daysToKeepFeedEntries() + delta = timedelta(days=daysToKeepFeedEntries) + return now - delta + class AbstractBackend(object): def __init__(self): self.feeds = [] @@ -27,10 +33,7 @@ return self.feedEntries def _calculateExpireDate(self): - now = datetime.now() - daysToKeepFeedEntries = self.preferences().daysToKeepFeedEntries() - delta = timedelta(days=daysToKeepFeedEntries) - return now - delta + return calculateExpireDate(self.preferences()) # # handling of the selected feed entry diff -r adf7f617bda9 -r f74fe7cb5091 backend/AbstractFeedUpdater.py --- a/backend/AbstractFeedUpdater.py Sat Jun 02 04:24:49 2012 +0200 +++ b/backend/AbstractFeedUpdater.py Sat Jun 02 04:30:04 2012 +0200 @@ -1,8 +1,9 @@ from datetime import datetime +from urllib2 import ProxyHandler +import AbstractBackend import feedparser import logging -from urllib2 import ProxyHandler STATUS_ERROR = 400 log = logging.getLogger("FeedUpdater") @@ -42,7 +43,8 @@ def _processEntries(self, feedDict): for entry in feedDict.entries: self._normalize(entry) - self._processEntry(entry) + if not self._isExpired(entry): + self._processEntry(entry) self._incrementFeedUpdateDate() def _normalize(self, entry): @@ -74,6 +76,10 @@ else: entry.summary = "" + def _isExpired(self, entry): + expireDate = AbstractBackend.calculateExpireDate(self.preferences) + return entry.updated_parsed < expireDate + def _processEntry(self, entry): raise Exception("_processEntry is abstract, subclasses must override")