diff options
-rw-r--r-- | pyaggr3g470r/controllers/feed.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/lib/crawler.py | 1 | ||||
-rw-r--r-- | pyaggr3g470r/templates/feed.html | 10 | ||||
-rw-r--r-- | pyaggr3g470r/templates/home.html | 6 | ||||
-rw-r--r-- | pyaggr3g470r/views/views.py | 6 |
5 files changed, 23 insertions, 2 deletions
diff --git a/pyaggr3g470r/controllers/feed.py b/pyaggr3g470r/controllers/feed.py index 286bea1e..a2455e2b 100644 --- a/pyaggr3g470r/controllers/feed.py +++ b/pyaggr3g470r/controllers/feed.py @@ -15,7 +15,7 @@ class FeedController(AbstractController): user = UserController(self.user_id).get(id=self.user_id) 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, enabled=True, + error_count__lt=max_error, enabled=True, last_retreived__lt=max_last).limit(limit)] if feeds: diff --git a/pyaggr3g470r/lib/crawler.py b/pyaggr3g470r/lib/crawler.py index 5525c7de..5e828dbf 100644 --- a/pyaggr3g470r/lib/crawler.py +++ b/pyaggr3g470r/lib/crawler.py @@ -129,6 +129,7 @@ class PyAggUpdater(AbstractCrawler): self.query_pyagg('put', 'feed/%d' % self.feed['id'], {'error_count': 0, 'etag': self.headers.get('etag', ''), + 'last_error': '', 'last_modified': self.headers.get('last-modified', '')}) diff --git a/pyaggr3g470r/templates/feed.html b/pyaggr3g470r/templates/feed.html index 21db7ebe..9910ccf7 100644 --- a/pyaggr3g470r/templates/feed.html +++ b/pyaggr3g470r/templates/feed.html @@ -14,6 +14,16 @@ ({{ ((feed.articles.all()|count * 100 ) / nb_articles) | round(2, 'floor') }}% {{ _('of the database') }}) {% endif %} .<br /> + {% if feed.error_count > 2 %} + <b>{{ _("That feed has encountered too much consecutive errors and won't be retreived anymore") }}</b> + {% elif feed.error_count > 0 %} + {{ _("That feed has encountered some errors but that counter will be reinitialized at the next successful retreiving") }} + {% endif %} + .<br /> + {% if feed.last_error %} + {{ _("Here's the last error encountered while retreiving this feed:") }} <pre>{{ feed.last_error }}</pre> + {% endif %} + {{ _('Address of the feed') }}: <a href="{{ feed.link }}">{{ feed.link }}</a><br /> {% if feed.site_link != "" %} {{ _('Address of the site') }}: <a href="{{ feed.site_link }}">{{ feed.site_link }}</a> diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index a00f962e..8170a99d 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -21,6 +21,9 @@ {% for fid, nbunread in unread|dictsort(by='value')|reverse %} <li class="feed-menu"><a href="{{ gen_url(feed=fid) }}"> {% if feed_id == fid %}<b>{% endif %} + {% if in_error.get(fid, 0) > 0 %} + <span style="background-color: {{ "red" if in_error[fid] > 2 else "orange" }} ;" class="badge pull-right" title="some errors occured while trying to retreive that feed">{{ in_error[fid] }}</span> + {% endif %} <span id="unread-{{ fid }}" class="badge pull-right">{{ nbunread }}</span> {{ feeds[fid]|safe }} {% if feed_id == fid %}</b>{% endif %} @@ -36,6 +39,9 @@ {% endfor %} {% for fid, ftitle in feeds|dictsort(case_sensitive=False, by='value') if not fid in unread %} <li class="feed-menu"><a href="{{ gen_url(feed=fid) }}"> + {% if in_error.get(fid, 0) > 0 %} + <span style="background-color: {{ "red" if in_error[fid] > 2 else "orange" }} ;" class="badge pull-right" title="some errors occured while trying to retreive that feed">{{ in_error[fid] }}</span> + {% endif %} {% if feed_id == fid %}<b>{% endif %} {{ ftitle|safe }} {% if feed_id == fid %}</b>{% endif %} diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index 66170a77..0f8fc04d 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -52,6 +52,7 @@ from pyaggr3g470r.models import User, Feed, Article, Role from pyaggr3g470r.decorators import feed_access_required from pyaggr3g470r.forms import SignupForm, SigninForm, AddFeedForm, \ ProfileForm, InformationMessageForm, RecoverPasswordForm +from pyaggr3g470r.controllers import FeedController if not conf.ON_HEROKU: import pyaggr3g470r.search as fastsearch @@ -246,11 +247,14 @@ def home(): unread = db.session.query(Article.feed_id, func.count(Article.id))\ .filter(Article.readed == False, Article.user_id == g.user.id)\ .group_by(Article.feed_id).all() + in_error = {feed.id: feed.error_count for feed in + FeedController(g.user.id).read(error_count__gt=0).all()} def gen_url(filter_=filter_, limit=limit, feed=feed_id): return '?filter_=%s&limit=%s&feed=%d' % (filter_, limit, feed) return render_template('home.html', gen_url=gen_url, feed_id=feed_id, filter_=filter_, limit=limit, feeds=feeds, - unread=dict(unread), articles=articles.all()) + unread=dict(unread), articles=articles.all(), + in_error=in_error) @app.route('/fetch', methods=['GET']) |