Commit a84b213a authored by Michal Čihař's avatar Michal Čihař

Do not update stats in every unit update

It's enough to do the full update in the end.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 83285524
......@@ -455,9 +455,9 @@ class Unit(models.Model):
unit=self,
)
if contentsum_changed:
self.update_has_failing_check(False)
self.update_has_comment()
self.update_has_suggestion()
self.update_has_failing_check(recurse=False, update_stats=False)
self.update_has_comment(update_stats=False)
self.update_has_suggestion(update_stats=False)
def is_plural(self):
"""
......@@ -881,7 +881,7 @@ class Unit(models.Model):
if was_change or is_new or not same_content:
self.update_has_failing_check(was_change)
def update_has_failing_check(self, recurse=False):
def update_has_failing_check(self, recurse=False, update_stats=True):
"""
Updates flag counting failing checks.
"""
......@@ -893,7 +893,8 @@ class Unit(models.Model):
self.save(backend=True, same_content=True, same_state=True)
# Update translation stats
self.translation.update_stats()
if update_stats:
self.translation.update_stats()
# Invalidate checks cache if there was any change
# (above code cares only about whether there is failing check
......@@ -904,7 +905,7 @@ class Unit(models.Model):
for unit in Unit.objects.same(self):
unit.update_has_failing_check(False)
def update_has_suggestion(self):
def update_has_suggestion(self, update_stats=True):
"""
Updates flag counting suggestions.
"""
......@@ -914,9 +915,10 @@ class Unit(models.Model):
self.save(backend=True, same_content=True, same_state=True)
# Update translation stats
self.translation.update_stats()
if update_stats:
self.translation.update_stats()
def update_has_comment(self):
def update_has_comment(self, update_stats=True):
"""
Updates flag counting comments.
"""
......@@ -926,7 +928,8 @@ class Unit(models.Model):
self.save(backend=True, same_content=True, same_state=True)
# Update translation stats
self.translation.update_stats()
if update_stats:
self.translation.update_stats()
def nearby(self):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment