Skip to content

Commit bf74954

Browse files
authored
Profile: don't duplicate annotation in queryset (#12405)
This is already done in the query iself #12385
1 parent 1293f5c commit bf74954

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""Template tags to query projects by privacy."""
22

33
from django import template
4-
from django.db.models import Exists
5-
from django.db.models import OuterRef
64

7-
from readthedocs.builds.models import Build
85
from readthedocs.core.permissions import AdminPermission
96
from readthedocs.projects.models import Project
107

@@ -24,14 +21,9 @@ def is_member(user, project):
2421

2522
@register.simple_tag(takes_context=True)
2623
def get_public_projects(context, user):
27-
# 'Exists()' checks if the project has any good builds.
28-
projects = (
29-
Project.objects.for_user_and_viewer(
30-
user=user,
31-
viewer=context["request"].user,
32-
)
33-
.prefetch_latest_build()
34-
.annotate(_good_build=Exists(Build.internal.filter(success=True, project=OuterRef("pk"))))
35-
)
24+
projects = Project.objects.for_user_and_viewer(
25+
user=user,
26+
viewer=context["request"].user,
27+
).prefetch_latest_build()
3628
context["public_projects"] = projects
3729
return ""

0 commit comments

Comments
 (0)