Merge pull request #5471 from saadmk11/dashboard-screen-performance-fix
Dashboard screen performance fixmaster
commit
c6daefe72f
|
@ -7,6 +7,7 @@ from celery import chain
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.db.models import Count, OuterRef, Subquery
|
||||||
from django.http import (
|
from django.http import (
|
||||||
Http404,
|
Http404,
|
||||||
HttpResponseBadRequest,
|
HttpResponseBadRequest,
|
||||||
|
@ -23,7 +24,7 @@ from formtools.wizard.views import SessionWizardView
|
||||||
from vanilla import CreateView, DeleteView, DetailView, GenericView, UpdateView
|
from vanilla import CreateView, DeleteView, DetailView, GenericView, UpdateView
|
||||||
|
|
||||||
from readthedocs.builds.forms import VersionForm
|
from readthedocs.builds.forms import VersionForm
|
||||||
from readthedocs.builds.models import Version
|
from readthedocs.builds.models import Build, Version
|
||||||
from readthedocs.core.mixins import ListViewWithForm, LoginRequiredMixin
|
from readthedocs.core.mixins import ListViewWithForm, LoginRequiredMixin
|
||||||
from readthedocs.core.utils import broadcast, prepare_build, trigger_build
|
from readthedocs.core.utils import broadcast, prepare_build, trigger_build
|
||||||
from readthedocs.integrations.models import HttpExchange, Integration
|
from readthedocs.integrations.models import HttpExchange, Integration
|
||||||
|
@ -92,7 +93,14 @@ class ProjectDashboard(PrivateViewMixin, ListView):
|
||||||
notification.send()
|
notification.send()
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Project.objects.dashboard(self.request.user)
|
# Filters the builds for a perticular project.
|
||||||
|
builds = Build.objects.filter(
|
||||||
|
project=OuterRef('pk'), type='html', state='finished')
|
||||||
|
# Creates a Subquery object which returns
|
||||||
|
# the value of Build.success of the latest build.
|
||||||
|
sub_query = Subquery(builds.values('success')[:1])
|
||||||
|
return Project.objects.dashboard(self.request.user).annotate(
|
||||||
|
build_count=Count('builds'), latest_build_success=sub_query)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.validate_primary_email(request.user)
|
self.validate_primary_email(request.user)
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
{% block project-name %}
|
{% block project-name %}
|
||||||
{{ project.name }}
|
{{ project.name }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% with builds=project.builds.count %}
|
{% with builds=project.build_count %}
|
||||||
{% if builds == 0 %}
|
{% if builds == 0 %}
|
||||||
<span class="right quiet">
|
<span class="right quiet">
|
||||||
{% trans "No builds yet" %}
|
{% trans "No builds yet" %}
|
||||||
|
@ -80,13 +80,11 @@
|
||||||
{{ builds }} builds
|
{{ builds }} builds
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</span>
|
</span>
|
||||||
{% with build=project.get_latest_build %}
|
{% if project.latest_build_success %}
|
||||||
{% if build.success %}
|
<span class="build-state build-state-passing">{% trans "passing" %}</span>
|
||||||
<span class="build-state build-state-passing">{% trans "passing" %}</span>
|
{% else %}
|
||||||
{% else %}
|
<span class="build-state build-state-failing">{% trans "failing" %}</span>
|
||||||
<span class="build-state build-state-failing">{% trans "failing" %}</span>
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% endwith %}
|
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
Loading…
Reference in New Issue