summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/update_search_vectors.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-16 19:59:32 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-16 19:59:32 +0100
commit7fcc49cd2da8e08dfcc879405ae9132634dc63f5 (patch)
treed337da44da290ca17f2cab7264d9ae17b3d72721 /ishtar_common/management/commands/update_search_vectors.py
parenta0e009c57998d6856db50f97b8baebefc8e16c10 (diff)
downloadIshtar-7fcc49cd2da8e08dfcc879405ae9132634dc63f5.tar.bz2
Ishtar-7fcc49cd2da8e08dfcc879405ae9132634dc63f5.zip
Update search vectors script: output total updated
Diffstat (limited to 'ishtar_common/management/commands/update_search_vectors.py')
-rw-r--r--ishtar_common/management/commands/update_search_vectors.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/ishtar_common/management/commands/update_search_vectors.py b/ishtar_common/management/commands/update_search_vectors.py
index f30f40f4e..59166fba7 100644
--- a/ishtar_common/management/commands/update_search_vectors.py
+++ b/ishtar_common/management/commands/update_search_vectors.py
@@ -21,6 +21,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
quiet = options['quiet']
+ total = 0
for model in django.apps.apps.get_models():
if options['model'] and model.__name__ != options['model']:
continue
@@ -32,6 +33,7 @@ class Command(BaseCommand):
if not quiet:
self.stdout.write("\n* update {}".format(model))
total = model.objects.count()
+ idx = 0
for idx, item in enumerate(model.objects.all()):
if not quiet:
sys.stdout.write("\r{}/{} ".format(idx + 1, total))
@@ -40,5 +42,7 @@ class Command(BaseCommand):
item.update_search_vector()
except:
pass
+ total += idx
if not quiet:
self.stdout.write("\n")
+ self.stdout.write("{} items updated\n".format(total))