Skip to content

Commit

Permalink
fix(unit): optimize fetching unit comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed May 3, 2024
1 parent 7ac414b commit a1939e2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions weblate/trans/models/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,13 +1298,12 @@ def active_checks(self):
@cached_property
def all_comments(self):
"""Return list of target comments."""
query = Q(unit=self)
if self.is_source:
# Add all comments on translation on source string comment
query |= Q(unit__source_unit=self)
query = Q(unit__source_unit=self)
else:
# Add source string comments for translation unit
query |= Q(unit=self.source_unit)
query = Q(unit__in=(self, self.source_unit))
return Comment.objects.filter(query).prefetch_related("unit", "user").order()

@cached_property
Expand Down

0 comments on commit a1939e2

Please sign in to comment.