Skip to content

Commit 2aef4be

Browse files
committed
Don't do extra query if the project is a translation
We only check for superprojects if the project isn't a translation. This reduces a query
1 parent 0e3df50 commit 2aef4be

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

readthedocs/core/resolver.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,17 @@ def _get_canonical_project(self, project, projects=None):
218218
# Track what projects have already been traversed to avoid infinite
219219
# recursion. We can't determine a root project well here, so you get
220220
# what you get if you have configured your project in a strange manner
221-
if projects is None:
222-
projects = [project]
223-
else:
224-
projects.append(project)
221+
projects = projects or set()
222+
projects.add(project)
225223

226224
next_project = None
227-
relation = project.get_parent_relationship()
228225
if project.main_language_project:
229226
next_project = project.main_language_project
230-
elif relation:
231-
next_project = relation.parent
227+
else:
228+
relation = project.get_parent_relationship()
229+
if relation:
230+
next_project = relation.parent
231+
232232
if next_project and next_project not in projects:
233233
return self._get_canonical_project(next_project, projects)
234234
return project

0 commit comments

Comments
 (0)