Skip to content

Commit

Permalink
fix: use union only when needed
Browse files Browse the repository at this point in the history
Shared components are rare so optimize for case when they are not used
and avoid using union query in that case.
  • Loading branch information
nijel committed Feb 20, 2025
1 parent ab82eb2 commit bcd59ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions weblate/trans/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,10 @@ def filter_access(qs):

def get_child_components_filter(self, filter_callback):
own = filter_callback(self.component_set.defer_huge())
shared = filter_callback(self.shared_components.defer_huge())
return own.union(shared)
if self.shared_components.exists():
shared = filter_callback(self.shared_components.defer_huge())
return own.union(shared)
return own

@cached_property
def child_components(self):
Expand Down

0 comments on commit bcd59ca

Please sign in to comment.