aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r--pyaggr3g470r/views.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index ef3b908e..0212e496 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -28,6 +28,7 @@ __license__ = "AGPLv3"
import os
import datetime
+from collections import namedtuple
from flask import abort, render_template, request, flash, session, \
url_for, redirect, g, current_app, make_response, jsonify
from flask.ext.login import LoginManager, login_user, logout_user, \
@@ -451,13 +452,11 @@ def unread(feed_id=None):
else:
feeds_with_unread = Feed.query.filter(Feed.user_id == g.user.id, Feed.articles.any(readed=False))
result, nb_unread = [], 0
+ light_feed = namedtuple('Feed', ['id', 'title', 'articles'], verbose=False, rename=False)
for feed in feeds_with_unread:
- new_feed = feed
- new_feed.articles = Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed.id, Article.readed == False).all()
- length = len(new_feed.articles.all())
- if length != 0:
- result.append(new_feed)
- nb_unread += length
+ articles = Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed.id, Article.readed == False).all()
+ result.append(light_feed(feed.id, feed.title, articles))
+ nb_unread += len(articles)
return render_template('unread.html', feeds=result, nb_unread=nb_unread)
@app.route('/inactives', methods=['GET'])
bgstack15