-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework homepage #3579
Rework homepage #3579
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,20 +39,8 @@ class HomepageView(TemplateView): | |
def get_context_data(self, **kwargs): | ||
"""Add latest builds and featured projects.""" | ||
context = super(HomepageView, self).get_context_data(**kwargs) | ||
latest = [] | ||
latest_builds = ( | ||
Build.objects | ||
.filter( | ||
project__privacy_level=constants.PUBLIC, | ||
success=True, | ||
) | ||
.order_by('-date') | ||
)[:100] # yapf: disable | ||
for build in latest_builds: | ||
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) | ||
context['projects_count'] = Project.objects.count() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I timed this against the prod database and it ran in ~20ms. If that's too expensive, we could consider caching it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be fine, but probably worth caching since that seems like a lot of time for no real reason. We can likely just use the Django view cache decorator at a minute or 5 minute interval, if we don't have anything much live updating! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if we can cache the whole page especially for logged in users. They have the username/dashboard fragment at the top. Perhaps we could do something with the |
||
return context | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a killer query for our DB as well. Glad to have it gone :)