From 185a6b4e48bbf0b1111bc5addace1f6ea5ec69f0 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 2 Dec 2012 23:34:22 +0100 Subject: New page (/inactives) which displays the list of inactive feeds since a certain number of days (given in parameter in the URL, 365 days by default). --- source/pyAggr3g470r.py | 19 +++++++++++++++++++ source/templates/inactives.html | 13 +++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 source/templates/inactives.html (limited to 'source') diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 72320dc4..afd30f72 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -757,6 +757,25 @@ class pyAggr3g470r(object): favorites.exposed = True + @require() + def inactives(self, nb_days=365): + """ + List of favorites articles + """ + feeds = self.mongo.get_all_feeds() + today = datetime.datetime.now() + 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)) + tmpl = lookup.get_template("inactives.html") + return tmpl.render(inactives=inactives, nb_days=int(nb_days)) + + inactives.exposed = True + @require() def add_feed(self, url): """ diff --git a/source/templates/inactives.html b/source/templates/inactives.html new file mode 100644 index 00000000..10a79e8e --- /dev/null +++ b/source/templates/inactives.html @@ -0,0 +1,13 @@ +## inactives.html +<%inherit file="base.html"/> +
+ %if inactives != []: +

Feeds with no recent articles since ${nb_days} days:

+ + %else: +

No inactive feeds.

+ %endif \ No newline at end of file -- cgit