From 4c1dc33a806920b46f5a05e244cfb7900aa8f08b Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 30 Dec 2012 11:21:28 +0100 Subject: Minor improvements to the /feed page. --- source/pyAggr3g470r.py | 15 ++++++--------- source/templates/feed.html | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 8652ec1a..f228781d 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -259,21 +259,18 @@ class pyAggr3g470r(object): nb_articles_feed = self.mongo.nb_articles(feed_id) nb_articles_total = self.mongo.nb_articles() nb_unread_articles_feed = self.mongo.nb_unread_articles(feed_id) + favorites = self.mongo.get_favorites(feed_id) except KeyError: return self.error("This feed do not exists.") if articles != []: - last_article = utils.string_to_datetime(str(articles[0]["article_date"])) - first_article = utils.string_to_datetime(str(articles[self.mongo.nb_articles(feed_id)-2]["article_date"])) - delta = last_article - first_article - - last_post = articles[0]["article_date"] today = datetime.datetime.now() - elapsed = today - last_post - + last_article = articles[0]["article_date"] + first_article = articles[self.mongo.nb_articles(feed_id)-2]["article_date"] + delta = last_article - first_article + elapsed = today - last_article + average = round(nb_articles_feed / abs(delta.days), 2) - average = round(float(nb_articles_feed) / abs(delta.days), 2) - favorites = self.mongo.get_favorites(feed_id) top_words = utils.top_words(articles = self.mongo.get_articles(feed_id), n=50, size=int(word_size)) tag_cloud = utils.tag_cloud(top_words) diff --git a/source/templates/feed.html b/source/templates/feed.html index 2edda630..01799fb7 100644 --- a/source/templates/feed.html +++ b/source/templates/feed.html @@ -18,7 +18,7 @@ import utils %if articles != []:

The last article was posted ${elapsed.days} day(s) ago.

-

Daily average: ${average}, between the ${first_post_date} and the ${end_post_date}.

+

Daily average: ${average}, between the ${first_post_date.strftime('%Y-%m-%d')} and the ${end_post_date.strftime('%Y-%m-%d')}.


-- cgit