summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/update_search_vectors.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-03-02 16:14:45 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2023-03-02 16:41:08 +0100
commit0dc167611a2f9fecc58b9709487362ceb3eb9752 (patch)
tree734d1eddcc720b9663852845862095979bc415a9 /ishtar_common/management/commands/update_search_vectors.py
parentf4d375c0e76b9d01bf5ac8311c220d5d80a55b41 (diff)
downloadIshtar-0dc167611a2f9fecc58b9709487362ceb3eb9752.tar.bz2
Ishtar-0dc167611a2f9fecc58b9709487362ceb3eb9752.zip
Maintenance scripts: delete deprecated and migrate to ishtar_maintenance
Diffstat (limited to 'ishtar_common/management/commands/update_search_vectors.py')
-rw-r--r--ishtar_common/management/commands/update_search_vectors.py48
1 files changed, 0 insertions, 48 deletions
diff --git a/ishtar_common/management/commands/update_search_vectors.py b/ishtar_common/management/commands/update_search_vectors.py
deleted file mode 100644
index a07da721e..000000000
--- a/ishtar_common/management/commands/update_search_vectors.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import sys
-
-from django.core.management.base import BaseCommand
-import django.apps
-
-
-class Command(BaseCommand):
- help = "./manage.py update_search_vectors\n\n"\
- "Update full texte search vectors."
-
- def add_arguments(self, parser):
- 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']
- nb_total = 0
- for model in django.apps.apps.get_models():
- if options['model'] and model.__name__ != options['model']:
- continue
- if hasattr(model, "update_search_vector") and \
- (getattr(model, "BASE_SEARCH_VECTORS", None) or
- getattr(model, "INT_SEARCH_VECTORS", None) or
- getattr(model, "M2M_SEARCH_VECTORS", None) or
- getattr(model, "PARENT_SEARCH_VECTORS", None)):
- 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))
- sys.stdout.flush()
- try:
- item.update_search_vector()
- except:
- pass
- nb_total += idx
- if not quiet:
- self.stdout.write("\n")
- self.stdout.write("{} items updated\n".format(nb_total))