Factor out stats updating
This commit is contained in:
parent
0ab1aabd03
commit
87d198909d
@ -226,13 +226,18 @@ class Translation(models.Model):
|
|||||||
Unit.objects.filter(translation = self, id__in = oldunits).delete()
|
Unit.objects.filter(translation = self, id__in = oldunits).delete()
|
||||||
|
|
||||||
# Update revision and stats
|
# Update revision and stats
|
||||||
|
self.update_stats(False)
|
||||||
|
self.revision = blob.hexsha
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
def update_stats(self, dosave = True):
|
||||||
total = self.unit_set.count()
|
total = self.unit_set.count()
|
||||||
fuzzy = self.unit_set.filter(fuzzy = True).count()
|
fuzzy = self.unit_set.filter(fuzzy = True).count()
|
||||||
translated = self.unit_set.filter(translated = True).count()
|
translated = self.unit_set.filter(translated = True).count()
|
||||||
self.fuzzy = round(fuzzy * 100.0 / total, 1)
|
self.fuzzy = round(fuzzy * 100.0 / total, 1)
|
||||||
self.translated = round(translated * 100.0 / total, 1)
|
self.translated = round(translated * 100.0 / total, 1)
|
||||||
self.revision = blob.hexsha
|
if dosave:
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def git_commit(self, author):
|
def git_commit(self, author):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user