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

Factor out index optimization

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 88cedfbf
...@@ -48,15 +48,19 @@ class Command(WeblateCommand): ...@@ -48,15 +48,19 @@ class Command(WeblateCommand):
), ),
) )
def optimize_index(self):
"""Optimizes index structures"""
index = get_source_index()
index.optimize()
languages = Language.objects.have_translation()
for lang in languages:
index = get_target_index(lang.code)
index.optimize()
def handle(self, *args, **options): def handle(self, *args, **options):
# Optimize index # Optimize index
if options['optimize']: if options['optimize']:
index = get_source_index() self.optimize_index()
index.optimize()
languages = Language.objects.have_translation()
for lang in languages:
index = get_target_index(lang.code)
index.optimize()
return return
# Optionally rebuild indices from scratch # Optionally rebuild indices from scratch
if options['clean']: if options['clean']:
...@@ -82,5 +86,5 @@ class Command(WeblateCommand): ...@@ -82,5 +86,5 @@ class Command(WeblateCommand):
finally: finally:
# Close all writers # Close all writers
source_writer.commit() source_writer.commit()
for lang in target_writers: for code in target_writers:
target_writers[lang].commit() target_writers[code].commit()
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