aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/controllers/feed.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-03-01 03:20:12 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-03-03 22:23:02 +0100
commit5572851eca3b2f1bc56aed7232284acc436d2f49 (patch)
treeb8f425333804ca06a4a16600b4c4c0bfcdf4cff7 /pyaggr3g470r/controllers/feed.py
parentcontinuing refacto (diff)
downloadnewspipe-5572851eca3b2f1bc56aed7232284acc436d2f49.tar.gz
newspipe-5572851eca3b2f1bc56aed7232284acc436d2f49.tar.bz2
newspipe-5572851eca3b2f1bc56aed7232284acc436d2f49.zip
new crawler with cache control and error handling
Diffstat (limited to 'pyaggr3g470r/controllers/feed.py')
-rw-r--r--pyaggr3g470r/controllers/feed.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/pyaggr3g470r/controllers/feed.py b/pyaggr3g470r/controllers/feed.py
index 56cef997..286bea1e 100644
--- a/pyaggr3g470r/controllers/feed.py
+++ b/pyaggr3g470r/controllers/feed.py
@@ -13,17 +13,12 @@ class FeedController(AbstractController):
from pyaggr3g470r.controllers import UserController
now = datetime.now()
user = UserController(self.user_id).get(id=self.user_id)
- max_last_refresh = now - timedelta(minutes=user.refresh_rate or 60)
+ max_last = now - timedelta(minutes=user.refresh_rate or 60)
feeds = [feed for feed in self.read(user_id=self.user_id,
- error_count__le=max_error,
- last_modified=max_last_refresh).limit(limit)]
+ error_count__le=max_error, enabled=True,
+ last_retreived__lt=max_last).limit(limit)]
- self.update({'id__in': [feed.id for feed in feeds]},
- {'last_modified': now})
+ if feeds:
+ self.update({'id__in': [feed.id for feed in feeds]},
+ {'last_retreived': now})
return feeds
-
- def list_last_articles(self, feed_id, limit=50):
- from pyaggr3g470r.controllers import ArticleController
- return ArticleController(self.user_id)._get(feed_id=feed_id)\
- .order_by(ArticleController._db_cls.retrieved_date.desc())\
- .limit(limit)
bgstack15