Skip to content

Cache get_project #8231

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

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions readthedocs/projects/views/base.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# -*- coding: utf-8 -*-

"""Mix-in classes for project views."""
import logging
from datetime import timedelta
from functools import lru_cache

from django.conf import settings
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils import timezone

from ..exceptions import ProjectSpamError
from ..models import Project

from readthedocs.projects.exceptions import ProjectSpamError
from readthedocs.projects.models import Project

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -64,6 +62,7 @@ def get_queryset(self):
self.project = self.get_project()
return self.model.objects.filter(project=self.project)

@lru_cache(maxsize=1)
def get_project(self):
"""Return project determined by url kwarg."""
if self.project_url_field not in self.kwargs:
Expand Down