-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Optimize resolve_path #6867
Optimize resolve_path #6867
Conversation
cname = ( | ||
cname | ||
or self._use_subdomain() | ||
or main_project.get_canonical_custom_domain() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were making use of the real cname
, but we only use it as a boolean value to see if we need to serve from /docs
instead of /
.
subproject_slug = relation.alias | ||
|
||
return (main_project, subproject_slug) | ||
|
||
def _get_canonical_project(self, project, projects=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can re-use the above method here if we don't't want to support more than 2 levels of relationships (thing that we already don't support actually...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment? re-use what method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is basically the same as _get_canonical_project_data
(when checking till 2 levels of relationships)
This together with: - #6867 - #6865 - #6864 reduces a lot of queries and without changing the current UI. This is a benchmark using the django debug toolbar: Before: 138 queries with 7 subprojects, 17 queries per each additional subproject With all the changes: 28 queries with 7 subprojects, 1 query per each additional subproject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good at first, but as with all resolver changes, it scares me a bit. A few small items.
subproject_slug = relation.alias | ||
|
||
return (main_project, subproject_slug) | ||
|
||
def _get_canonical_project(self, project, projects=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment? re-use what method?
I can split this PR into 3 PRs if that makes it more easy |
I think it's just scary in general, more PRs wont make it less scary :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but I'd like to write up some QA steps in the release project before we merge it, if you have some ideas for that.
@@ -204,6 +188,68 @@ def resolve( | |||
) | |||
return urlunparse((protocol, domain, path, '', query_params, '')) | |||
|
|||
def _get_canonical_project_data(self, project): | |||
""" | |||
Returns a tuple with (project, subproject_slug) from the canonical project of `project`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 docstring!
I have added some projects to check on the release card |
This reduces: 2 queries for "normal" projects; and 4 for "complex" projects.
There are only 2 tests falling
readthedocs.org/readthedocs/rtd_tests/tests/test_resolver.py
Lines 260 to 284 in b72343f
But can't find a place where we call the resolver with a wrong language, we usually do
readthedocs.org/readthedocs/builds/models.py
Lines 369 to 374 in 3ee8b93
Notes:
One 1 test pass with the old and new code, I think the other one we need to agree with what the "canonical" project is.We decided to not support subprojects of translations for now.ref #6455