blob: 8ab5aeb8e2aa7c6b1a980aa41d34a2a62e7ba99c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import sys
from django.core.management.base import BaseCommand
from chimere import models
class Command(BaseCommand):
help = "Update internal search engine"
def handle(self, *args, **options):
for model in [models.Marker, models.Route, models.Polygon]:
sys.stdout.write("* {}\n".format(model))
changed = 0
q = model.objects
total = q.count()
for idx, item in enumerate(q.all()):
sys.stdout.write("{}/{}\r".format(idx + 1, total))
sys.stdout.flush()
changed += 1 if item.update_search_vector() else 0
print("{} item(s) updated".format(changed))
|