diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-16 19:46:48 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-16 19:46:48 +0100 |
commit | 771afa9940dd9ecb4c935189f30d553bcd020801 (patch) | |
tree | 05e2455b93fb0493c72c3fdd3ecb8496641b0193 | |
parent | 21c279169a50bd7314a339cf3dd75b36fcbe0228 (diff) | |
download | Ishtar-771afa9940dd9ecb4c935189f30d553bcd020801.tar.bz2 Ishtar-771afa9940dd9ecb4c935189f30d553bcd020801.zip |
Quiet option for update search vectors
-rw-r--r-- | ishtar_common/management/commands/update_search_vectors.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ishtar_common/management/commands/update_search_vectors.py b/ishtar_common/management/commands/update_search_vectors.py index 9fa93277c..f30f40f4e 100644 --- a/ishtar_common/management/commands/update_search_vectors.py +++ b/ishtar_common/management/commands/update_search_vectors.py @@ -15,8 +15,12 @@ class Command(BaseCommand): parser.add_argument( '--model', type=str, default='', dest='model', help='Specific model to update') + parser.add_argument( + '--quiet', dest='quiet', action='store_true', + help='Quiet output') def handle(self, *args, **options): + quiet = options['quiet'] for model in django.apps.apps.get_models(): if options['model'] and model.__name__ != options['model']: continue @@ -25,13 +29,16 @@ class Command(BaseCommand): getattr(model, "INT_SEARCH_VECTORS", None) or getattr(model, "M2M_SEARCH_VECTORS", None) or getattr(model, "PARENT_SEARCH_VECTORS", None)): - self.stdout.write("\n* update {}".format(model)) + if not quiet: + self.stdout.write("\n* update {}".format(model)) total = model.objects.count() for idx, item in enumerate(model.objects.all()): - sys.stdout.write("\r{}/{} ".format(idx + 1, total)) - sys.stdout.flush() + if not quiet: + sys.stdout.write("\r{}/{} ".format(idx + 1, total)) + sys.stdout.flush() try: item.update_search_vector() except: pass - self.stdout.write("\n") + if not quiet: + self.stdout.write("\n") |