Use naive queryset instead, due to missing indexes and performance hit

team-project-import
Anthony Johnson 2015-11-29 01:17:47 -08:00
parent 92cc525794
commit 2c57e9414b
1 changed files with 9 additions and 5 deletions

View File

@ -52,12 +52,16 @@ class HomepageView(DonateProgressMixin, TemplateView):
'''Add latest builds and featured projects'''
context = super(HomepageView, self).get_context_data(**kwargs)
latest = []
latest_builds = Build.objects.order_by('-date')[:100]
latest_builds = (
Build.objects
.filter(
project__privacy_level=constants.PUBLIC,
success=True,
)
.order_by('-date')
)[:100]
for build in latest_builds:
if (
build.project.privacy_level == constants.PUBLIC and
build.project not in latest and
len(latest) < 10):
if (build.project not in latest and len(latest) < 10):
latest.append(build.project)
context['project_list'] = latest
context['featured_list'] = Project.objects.filter(featured=True)