Commit 8838e553 authored by Michal Čihař's avatar Michal Čihař

Further optimize getting list of units to process

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent d2225bf6
......@@ -45,8 +45,11 @@ class WeblateCommand(BaseCommand):
'''
Returns list of units matching parameters.
'''
translations = self.get_translations(*args, **options)
return Unit.objects.filter(translation__in=translations)
if options['all']:
return Unit.objects.all()
return Unit.objects.filter(
translation__subproject__in=self.get_subprojects(*args, **options)
)
def get_translations(self, *args, **options):
'''
......@@ -118,6 +121,19 @@ class WeblateLangCommand(WeblateCommand):
),
)
def get_units(self, *args, **options):
'''
Returns list of units matching parameters.
'''
if options['all']:
if options['lang'] is not None:
return Unit.objects.filter(
translation__language__code=options['lang']
)
return Unit.objects.all()
return super(WeblateLangCommand, self).get_units(*args, **options)
def get_translations(self, *args, **options):
'''
Returns list of translations matching parameters.
......
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