From e027acfc3463447aa974bcbcdec324bc2c032aee Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 29 Mar 2013 07:26:27 +0100 Subject: The original epoch time (time.gmtime(0)) is now used as last_post_date when there is no article in a feed. --- source/pyAggr3g470r.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 8b222f68..116689c9 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -44,6 +44,7 @@ __license__ = "GPLv3" import os import re +import time import datetime from collections import defaultdict @@ -443,11 +444,13 @@ class pyAggr3g470r(object): inactives = [] for feed in feeds: more_recent_article = self.mongo.get_articles(feed["feed_id"], limit=1) - if more_recent_article.count() != 0: + if more_recent_article.count() == 0: + last_post = datetime.datetime.fromtimestamp(time.mktime(time.gmtime(0))) + else: last_post = next(more_recent_article)["article_date"] - elapsed = today - last_post - if elapsed > datetime.timedelta(days=int(nb_days)): - inactives.append((feed, elapsed)) + 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