Commit 9eb163c2 authored by Michal Čihař's avatar Michal Čihař

Remove suggestions matching current translation on cleanup

parent f9153ca1
......@@ -8,7 +8,14 @@ class Command(BaseCommand):
def handle(self, *args, **options):
for lang in Language.objects.all():
for prj in Project.objects.all():
# Remove checks referring to deleted or not translated units
translatedunits = Unit.objects.filter(translation__language = lang, translated = True, translation__subproject__project = prj).values('checksum').distinct()
Check.objects.filter(language = lang, project = prj).exclude(checksum__in = translatedunits).delete()
# Remove suggestions referring to deleted units
units = Unit.objects.filter(translation__language = lang, translation__subproject__project = prj).values('checksum').distinct()
Suggestion.objects.filter(language = lang, project = prj).exclude(checksum__in = units).delete()
# Remove suggestions with same text as real translation
for sug in Suggestion.objects.filter(language = lang, project = prj).iterator():
units = Unit.objects.filter(checksum = sug.checksum, translation__language = lang, translation__subproject__project = prj, target = sug.target)
if units.count() > 0:
sug.delete()
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