summaryrefslogtreecommitdiff
path: root/ishtar_common/management
diff options
context:
space:
mode:
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
commita0e009c57998d6856db50f97b8baebefc8e16c10 (patch)
tree05e2455b93fb0493c72c3fdd3ecb8496641b0193 /ishtar_common/management
parentb2927bbe7719bf36cafb250d38c0089d9466b94d (diff)
downloadIshtar-a0e009c57998d6856db50f97b8baebefc8e16c10.tar.bz2
Ishtar-a0e009c57998d6856db50f97b8baebefc8e16c10.zip
Quiet option for update search vectors
Diffstat (limited to 'ishtar_common/management')
-rw-r--r--ishtar_common/management/commands/update_search_vectors.py15
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")