summaryrefslogtreecommitdiffstats
path: root/feeds.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-10-19 14:19:05 -0500
committerDan McGee <dan@archlinux.org>2014-10-19 14:19:05 -0500
commit1ff2e37e049004852681794537417a1947bf6f18 (patch)
tree09ab371e9c0d8a4067ac04ea5715ae53ac2ae2b3 /feeds.py
parent7c26f6b7a4d29faede58d2feb13ef961e4725637 (diff)
downloadarchweb-1ff2e37e049004852681794537417a1947bf6f18.tar.gz
archweb-1ff2e37e049004852681794537417a1947bf6f18.zip
Simplify last modified and etags processing for feeds
We had this elaborate system set up with caching and invalidation, which is overkill since we cache the result of the view anyway. Just hit the database when needed to find the last change to the respective model class and be done with it. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'feeds.py')
-rw-r--r--feeds.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/feeds.py b/feeds.py
index feb8a84a..d1836178 100644
--- a/feeds.py
+++ b/feeds.py
@@ -4,11 +4,11 @@ from pytz import utc
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
+from django.db import connection
from django.db.models import Q
from django.utils.feedgenerator import Rss201rev2Feed
from django.views.decorators.http import condition
-from main.utils import retrieve_latest
from main.models import Arch, Repo, Package
from news.models import News
from releng.models import Release
@@ -64,13 +64,15 @@ class GuidNotPermalinkFeed(Rss201rev2Feed):
def package_etag(request, *args, **kwargs):
- latest = retrieve_latest(Package)
+ latest = package_last_modified(request)
if latest:
return hashlib.md5(str(kwargs) + str(latest)).hexdigest()
return None
def package_last_modified(request, *args, **kwargs):
- return retrieve_latest(Package)
+ cursor = connection.cursor()
+ cursor.execute("SELECT MAX(last_update) FROM packages")
+ return cursor.fetchone()[0]
class PackageFeed(Feed):
@@ -148,13 +150,15 @@ class PackageFeed(Feed):
def news_etag(request, *args, **kwargs):
- latest = retrieve_latest(News, 'last_modified')
+ latest = news_last_modified(request)
if latest:
return hashlib.md5(str(latest)).hexdigest()
return None
def news_last_modified(request, *args, **kwargs):
- return retrieve_latest(News, 'last_modified')
+ cursor = connection.cursor()
+ cursor.execute("SELECT MAX(last_modified) FROM news")
+ return cursor.fetchone()[0]
class NewsFeed(Feed):