Only index news items 4 years or younger
authorMagnus Hagander <magnus@hagander.net>
Tue, 12 Jul 2011 13:17:29 +0000 (14:17 +0100)
committerMagnus Hagander <magnus@hagander.net>
Tue, 12 Jul 2011 13:17:29 +0000 (14:17 +0100)
pgweb/news/struct.py

index 704dd875044d5c940d86c395ee41db193ef89982..e1112aa5e844795ee883dc604e0ad10c65193051 100644 (file)
@@ -1,14 +1,16 @@
 import os
-from datetime import date
+from datetime import date, timedelta
 from models import NewsArticle
 
 def get_struct():
        now = date.today()
+       fouryearsago = date.today() - timedelta(4*365, 0, 0)
 
        # We intentionally don't put /about/newsarchive/ in the sitemap,
        # since we don't care about getting it indexed.
+       # Also, don't bother indexing anything > 4 years old
 
-       for n in NewsArticle.objects.filter(approved=True):
+       for n in NewsArticle.objects.filter(approved=True, date__gt=fouryearsago):
                yearsold = (now - n.date).days / 365
                if yearsold > 4:
                        yearsold = 4