aboutsummaryrefslogtreecommitdiff
path: root/source/pyAggr3g470r.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-03-29 07:26:27 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-03-29 07:26:27 +0100
commite027acfc3463447aa974bcbcdec324bc2c032aee (patch)
tree1666fc53e82b1d04482fb6e3aca79ad1a189b4d1 /source/pyAggr3g470r.py
parentAdded the case when the feed is empty for the /articles view. (diff)
downloadnewspipe-e027acfc3463447aa974bcbcdec324bc2c032aee.tar.gz
newspipe-e027acfc3463447aa974bcbcdec324bc2c032aee.tar.bz2
newspipe-e027acfc3463447aa974bcbcdec324bc2c032aee.zip
The original epoch time (time.gmtime(0)) is now used as last_post_date when there is no article in a feed.
Diffstat (limited to 'source/pyAggr3g470r.py')
-rwxr-xr-xsource/pyAggr3g470r.py11
1 files changed, 7 insertions, 4 deletions
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))
bgstack15