From 6776bd3e56cd5b3b8d26102bf6e5f2337bba7529 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 28 Mar 2013 09:56:11 +0100 Subject: Minor fix to the /inactives view when a feed has no articles. --- source/pyAggr3g470r.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 5a55cacf..8b222f68 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -443,10 +443,11 @@ class pyAggr3g470r(object): inactives = [] for feed in feeds: more_recent_article = self.mongo.get_articles(feed["feed_id"], limit=1) - last_post = next(more_recent_article)["article_date"] - elapsed = today - last_post - if elapsed > datetime.timedelta(days=int(nb_days)): - inactives.append((feed, elapsed)) + if more_recent_article.count() != 0: + last_post = next(more_recent_article)["article_date"] + elapsed = today - last_post + if elapsed > datetime.timedelta(days=int(nb_days)): + inactives.append((feed, elapsed)) tmpl = lookup.get_template("inactives.html") return tmpl.render(inactives=inactives, nb_days=int(nb_days)) -- cgit