harvest-dev team mailing list archive
-
harvest-dev team
-
Mailing list archive
-
Message #00622
[Merge] lp:~nigelbabu/harvest/cache-add into lp:harvest
Nigel Babu has proposed merging lp:~nigelbabu/harvest/cache-add into lp:harvest.
Requested reviews:
harvest-dev (harvest-dev)
For more details, see:
https://code.launchpad.net/~nigelbabu/harvest/cache-add/+merge/71904
Try to add some caching and reducing the DB load for '/'
--
https://code.launchpad.net/~nigelbabu/harvest/cache-add/+merge/71904
Your team harvest-dev is requested to review the proposed merge of lp:~nigelbabu/harvest/cache-add into lp:harvest.
=== modified file 'harvest/common/views.py'
--- harvest/common/views.py 2010-12-08 08:15:50 +0000
+++ harvest/common/views.py 2011-08-17 14:47:25 +0000
@@ -4,9 +4,11 @@
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
+from django.views.decorators.cache import cache_page
from opportunities.models import SourcePackage, OpportunityList, Opportunity, Note
+@cache_page(60 * 15)
def index(request):
context = {
@@ -14,8 +16,7 @@
'users': User.objects.count(),
'sourcepackages': SourcePackage.objects.count(),
'opportunitylists': OpportunityList.objects.filter(active=True).count(),
- 'opportunities': Opportunity.objects.filter(valid=True,
- last_updated=F('opportunitylist__last_updated')).count(),
+ 'opportunities': Opportunity.objects.only_valid().count(),
'notes': Note.objects.count(),
}
return render_to_response('index.html', context,
=== modified file 'harvest/settings.py'
--- harvest/settings.py 2011-06-28 13:42:41 +0000
+++ harvest/settings.py 2011-08-17 14:47:25 +0000
@@ -162,4 +162,4 @@
VERSION_NAME_STRING = utils.get_harvest_version_name(
os.path.join(PROJECT_PATH, "version"),
DEBUG)
-
+CACHE_BACKEND = 'locmem://'
Follow ups