Skip to content
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

Refactor footer_html view to class #6125

Merged
merged 4 commits into from Aug 30, 2019

Conversation

@stsewd
Copy link
Member

commented Aug 30, 2019

This is going to help us to extend this view more easily
from the corporate site.

Logic is the same, just code was moved.

stsewd added 2 commits Aug 30, 2019
Refactor footer_html view to class
This is going to help us to extend this view more easily
from the corporate site.

@stsewd stsewd requested review from ericholscher and readthedocs/core Aug 30, 2019

@ericholscher
Copy link
Member

left a comment

Good refactor 👍

readthedocs/api/v2/views/footer_views.py Show resolved Hide resolved
if not project:
project_slug = self.request.GET.get('project', None)
project = get_object_or_404(Project, slug=project_slug)
setattr(self, cache_key, project)

This comment has been minimized.

Copy link
@ericholscher

ericholscher Aug 30, 2019

Member

Should we actually be using the real Django cache, and caching these across lookups? That would make it so we never have to hit the DB in the footer in normal cases.

Probably doesn't make sense, but worth a thought.

This comment has been minimized.

Copy link
@stsewd

stsewd Aug 30, 2019

Author Member

Do you mean cache the view or the model? I'm opening a new issue to follow up.

This comment has been minimized.

Copy link
@stsewd
readthedocs/api/v2/views/footer_views.py Show resolved Hide resolved
stsewd added 2 commits Aug 30, 2019
@stsewd stsewd referenced this pull request Aug 30, 2019

@stsewd stsewd merged commit 34d1a15 into readthedocs:master Aug 30, 2019

2 checks passed

continuous-documentation/read-the-docs Read the Docs build succeeded!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@stsewd stsewd deleted the stsewd:stsewd/refactor-footer-html-view branch Aug 30, 2019

renderer_classes = [JSONRenderer, JSONPRenderer]

def _get_project(self):
cache_key = '_cached_project'

This comment has been minimized.

Copy link
@humitos

humitos Sep 4, 2019

Member

These cache keys should have a more specific prefix, like: footerhtml_cached_project. Otherwise, it's easy to override by mistake.

This comment has been minimized.

Copy link
@ericholscher

ericholscher Sep 5, 2019

Member

It's an attribute on the class, so it's naturally scoped I think.

This comment has been minimized.

Copy link
@humitos

humitos Sep 5, 2019

Member

Oh, right. We will need to change it if we move into a shared cache as you suggested, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.