aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/controllers
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-04-22 11:06:27 +0200
committerCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-04-22 11:06:27 +0200
commit4fa09afdb7465db6730cb69a9f99279afdb0cf87 (patch)
treeec221bc4fc68389fb58672cd01b34bf1740c43b0 /pyaggr3g470r/controllers
parentUpdated NEWS.rst (diff)
parentimpacting wosh suppression to controller (diff)
downloadnewspipe-4fa09afdb7465db6730cb69a9f99279afdb0cf87.tar.gz
newspipe-4fa09afdb7465db6730cb69a9f99279afdb0cf87.tar.bz2
newspipe-4fa09afdb7465db6730cb69a9f99279afdb0cf87.zip
Merged in jaesivsm/pyaggr3g470r (pull request #11)
misc improvement in http crawler
Diffstat (limited to 'pyaggr3g470r/controllers')
-rw-r--r--pyaggr3g470r/controllers/abstract.py4
-rw-r--r--pyaggr3g470r/controllers/article.py8
-rw-r--r--pyaggr3g470r/controllers/feed.py10
3 files changed, 8 insertions, 14 deletions
diff --git a/pyaggr3g470r/controllers/abstract.py b/pyaggr3g470r/controllers/abstract.py
index 9a9004af..95f9e211 100644
--- a/pyaggr3g470r/controllers/abstract.py
+++ b/pyaggr3g470r/controllers/abstract.py
@@ -70,7 +70,9 @@ class AbstractController(object):
def create(self, **attrs):
assert self._user_id_key in attrs or self.user_id is not None, \
"You must provide user_id one way or another"
- attrs[self._user_id_key] = self.user_id or attrs.get(self._user_id_key)
+
+ if self._user_id_key not in attrs:
+ attrs[self._user_id_key] = self.user_id
obj = self._db_cls(**attrs)
db.session.add(obj)
db.session.commit()
diff --git a/pyaggr3g470r/controllers/article.py b/pyaggr3g470r/controllers/article.py
index 0ec53a2f..bcd73e99 100644
--- a/pyaggr3g470r/controllers/article.py
+++ b/pyaggr3g470r/controllers/article.py
@@ -1,7 +1,6 @@
from sqlalchemy import func
from bootstrap import db
-import conf
from .abstract import AbstractController
from pyaggr3g470r.models import Article
@@ -15,13 +14,6 @@ class ArticleController(AbstractController):
self.update({'id': article.id}, {'readed': True})
return article
- def delete(self, obj_id):
- obj = super(ArticleController, self).delete(obj_id)
- if not conf.ON_HEROKU:
- import pyaggr3g470r.search as fastsearch
- fastsearch.delete_article(self.user_id, obj.feed_id, obj_id)
- return obj
-
def challenge(self, ids):
"""Will return each id that wasn't found in the database."""
for id_ in ids:
diff --git a/pyaggr3g470r/controllers/feed.py b/pyaggr3g470r/controllers/feed.py
index 8db279ae..82714e39 100644
--- a/pyaggr3g470r/controllers/feed.py
+++ b/pyaggr3g470r/controllers/feed.py
@@ -27,8 +27,9 @@ from .abstract import AbstractController
from pyaggr3g470r.models import Feed
logger = logging.getLogger(__name__)
-DEFAULT_MAX_ERROR = conf.DEFAULT_MAX_ERROR
DEFAULT_LIMIT = 5
+DEFAULT_REFRESH_RATE = 60
+DEFAULT_MAX_ERROR = conf.DEFAULT_MAX_ERROR
class FeedController(AbstractController):
@@ -42,11 +43,10 @@ class FeedController(AbstractController):
.order_by('Feed.last_retrieved')
.limit(limit)]
- def list_fetchable(self, max_error=DEFAULT_MAX_ERROR, limit=DEFAULT_LIMIT):
- from pyaggr3g470r.controllers import UserController
+ def list_fetchable(self, max_error=DEFAULT_MAX_ERROR, limit=DEFAULT_LIMIT,
+ refresh_rate=DEFAULT_REFRESH_RATE):
now = datetime.now()
- user = UserController(self.user_id).get(id=self.user_id)
- max_last = now - timedelta(minutes=user.refresh_rate or 60)
+ max_last = now - timedelta(minutes=refresh_rate)
feeds = self.list_late(max_last, max_error, limit)
if feeds:
self.update({'id__in': [feed.id for feed in feeds]},
bgstack15