Skip to content

Commit 1293f5c

Browse files
authored
Dashboard: cache get_queryset (#12399)
On .org this doesn't reduce the number of queries, but it does for .com
1 parent f1f27e3 commit 1293f5c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

readthedocs/projects/views/private.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Project views for authenticated users."""
22

3+
from functools import lru_cache
4+
35
import structlog
46
from django.conf import settings
57
from django.contrib import messages
@@ -149,6 +151,10 @@ def validate_primary_email(self, user):
149151
dismissable=True,
150152
)
151153

154+
# NOTE: This method is called twice, on .org it doesn't matter,
155+
# as the queryset is straightforward, but on .com it
156+
# does some extra work that results in several queries.
157+
@lru_cache(maxsize=1)
152158
def get_queryset(self):
153159
return Project.objects.dashboard(self.request.user)
154160

0 commit comments

Comments
 (0)