|
7 | 7 | from django.contrib import messages
|
8 | 8 | from django.contrib.auth.decorators import login_required
|
9 | 9 | from django.contrib.auth.models import User
|
| 10 | +from django.db.models import Count, OuterRef, Subquery |
10 | 11 | from django.http import (
|
11 | 12 | Http404,
|
12 | 13 | HttpResponseBadRequest,
|
|
23 | 24 | from vanilla import CreateView, DeleteView, DetailView, GenericView, UpdateView
|
24 | 25 |
|
25 | 26 | from readthedocs.builds.forms import VersionForm
|
26 |
| -from readthedocs.builds.models import Version |
| 27 | +from readthedocs.builds.models import Build, Version |
27 | 28 | from readthedocs.core.mixins import ListViewWithForm, LoginRequiredMixin
|
28 | 29 | from readthedocs.core.utils import broadcast, prepare_build, trigger_build
|
29 | 30 | from readthedocs.integrations.models import HttpExchange, Integration
|
@@ -92,7 +93,11 @@ def validate_primary_email(self, user):
|
92 | 93 | notification.send()
|
93 | 94 |
|
94 | 95 | def get_queryset(self):
|
95 |
| - return Project.objects.dashboard(self.request.user) |
| 96 | + builds = Build.objects.filter( |
| 97 | + project=OuterRef('pk'), type='html', state='finished') |
| 98 | + sub_query = Subquery(builds.values('success')[:1]) |
| 99 | + return Project.objects.dashboard(self.request.user).annotate( |
| 100 | + Count('builds'), build_success=sub_query) |
96 | 101 |
|
97 | 102 | def get(self, request, *args, **kwargs):
|
98 | 103 | self.validate_primary_email(request.user)
|
|
0 commit comments