aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/controllers')
-rw-r--r--pyaggr3g470r/controllers/abstract.py2
-rw-r--r--pyaggr3g470r/controllers/article.py6
-rw-r--r--pyaggr3g470r/controllers/feed.py10
3 files changed, 12 insertions, 6 deletions
diff --git a/pyaggr3g470r/controllers/abstract.py b/pyaggr3g470r/controllers/abstract.py
index 8960c3be..6fe45461 100644
--- a/pyaggr3g470r/controllers/abstract.py
+++ b/pyaggr3g470r/controllers/abstract.py
@@ -13,7 +13,7 @@ class AbstractController(object):
if self.user_id:
filters[self._user_id_key] = self.user_id
db_filters = set()
- for key, value in filters.iteritems():
+ for key, value in filters.items():
if key.endswith('__gt'):
db_filters.add(getattr(self._db_cls, key[:-4]) > value)
elif key.endswith('__lt'):
diff --git a/pyaggr3g470r/controllers/article.py b/pyaggr3g470r/controllers/article.py
index cfaf386d..0de223ee 100644
--- a/pyaggr3g470r/controllers/article.py
+++ b/pyaggr3g470r/controllers/article.py
@@ -6,10 +6,10 @@ from pyaggr3g470r.models import Article
class ArticleController(AbstractController):
_db_cls = Article
- def read(self, obj_id):
- article = super(ArticleController, self).read(obj_id)
+ def get(self, **filters):
+ article = super(ArticleController, self).read(**filters)
if not article.readed:
- self.update(obj_id, readed=True)
+ self.update(article.id, readed=True)
return article
def delete(self, obj_id):
diff --git a/pyaggr3g470r/controllers/feed.py b/pyaggr3g470r/controllers/feed.py
index ce1c413f..56cef997 100644
--- a/pyaggr3g470r/controllers/feed.py
+++ b/pyaggr3g470r/controllers/feed.py
@@ -16,8 +16,14 @@ class FeedController(AbstractController):
max_last_refresh = 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_refreshed__lt=max_last_refresh).limit(limit)]
+ last_modified=max_last_refresh).limit(limit)]
self.update({'id__in': [feed.id for feed in feeds]},
- {'last_refreshed': now})
+ {'last_modified': 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