bodhi/config/app.cfg | 4 ++++ bodhi/rss.py | 31 ++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-)
New commits: commit f8999e34bebaeb25f37bde7c86f78dfcc229b6c1 Author: Luke Macken lmacken@redhat.com Date: Tue Jul 20 16:56:03 2010 -0400
Show the past `feeds.num_days_to_show` worth of updates. If that number is less than `feeds.max_entries`, then backfill the rest.
This addresses Till's concerns in [ticket:339]
diff --git a/bodhi/config/app.cfg b/bodhi/config/app.cfg index d85c9d7..419bcb1 100644 --- a/bodhi/config/app.cfg +++ b/bodhi/config/app.cfg @@ -173,6 +173,10 @@ critpath.min_karma = 2
# The commented out values below are the defaults
+# The number of days worth of updates/comments to display +feeds.num_days_to_show = 7 +feeds.max_entries = 20 + # VIEW
# which view (template engine) to use if one is not specified in the diff --git a/bodhi/rss.py b/bodhi/rss.py index fb4849e..d763660 100644 --- a/bodhi/rss.py +++ b/bodhi/rss.py @@ -13,6 +13,7 @@
import logging
+from datetime import datetime from turbogears.feed import FeedController from turbogears import config, url from sqlobject import SQLObjectNotFound @@ -74,9 +75,13 @@ class Feed(FeedController): query.append(PackageUpdate.q.builds == builds) title.append("for %s" % builds)
- updates = PackageUpdate.select(AND(*query), orderBy=order).reversed()[:20] + updates = PackageUpdate.select(AND(*query), orderBy=order).reversed()
for update in updates: + delta = datetime.utcnow() - update.date_submitted + if delta and delta.days > config.get('feeds.num_days_to_show'): + if len(entries) >= config.get('feeds.max_entries'): + break entries.append({ 'id' : config.get('base_address') + url(update.get_url()), 'summary' : update.notes, @@ -108,11 +113,16 @@ class Feed(FeedController): entries = [] if user: comments = Comment.select(Comment.q.author == user, - orderBy=Comment.q.timestamp).reversed()[:20] + orderBy=Comment.q.timestamp).reversed() else: comments = Comment.select(Comment.q.author != 'bodhi', - orderBy=Comment.q.timestamp).reversed()[:20] + orderBy=Comment.q.timestamp).reversed() for comment in comments: + delta = datetime.utcnow() - comment.update.date_submitted + if delta and delta.days > config.get('feeds.num_days_to_show'): + if len(entries) >= config.get('feeds.max_entries'): + break + entries.append({ 'id' : config.get('base_address') + \ url(comment.update.get_url()), @@ -136,8 +146,11 @@ class Feed(FeedController): pkg = Package.byName(package) base = config.get('base_address') for i, update in enumerate(pkg.updates()): - if i >= 20: - break + delta = datetime.utcnow() - update.date_submitted + if delta and delta.days > config.get('feeds.num_days_to_show'): + if len(entries) >= config.get('feeds.max_entries'): + break + entries.append({ 'id' : base + url(update.get_url()), 'summary' : update.notes, @@ -172,8 +185,12 @@ class Feed(FeedController): for release in releases]), *query), orderBy=PackageUpdate.q.date_submitted).reversed(): - if i >= 20: - break + + delta = datetime.utcnow() - update.date_submitted + if delta and delta.days > config.get('feeds.num_days_to_show'): + if len(entries) >= config.get('feeds.max_entries'): + break + if update.critpath: if unapproved: if update.critpath_approved: