|
@@ -11,21 +11,18 @@ class Command(BaseCommand):
|
|
|
help = "Rebuilds posts search"
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
- posts_to_sync = Post.objects.filter(is_event=False).count()
|
|
|
+ posts_to_reindex = Post.objects.filter(is_event=False).count()
|
|
|
|
|
|
- if not posts_to_sync:
|
|
|
+ if not posts_to_reindex:
|
|
|
self.stdout.write("\n\nNo posts were found")
|
|
|
else:
|
|
|
- self.sync_threads(posts_to_sync)
|
|
|
+ self.rebuild_posts_search(posts_to_reindex)
|
|
|
|
|
|
- def sync_threads(self, posts_to_sync):
|
|
|
- message = "Rebuilding %s posts...\n"
|
|
|
- self.stdout.write(message % posts_to_sync)
|
|
|
+ def rebuild_posts_search(self, posts_to_reindex):
|
|
|
+ self.stdout.write("Rebuilding search for {} posts...\n".format(posts_to_reindex))
|
|
|
|
|
|
- message = "\n\nRebuild %s posts"
|
|
|
-
|
|
|
- synchronized_count = 0
|
|
|
- show_progress(self, synchronized_count, posts_to_sync)
|
|
|
+ rebuild_count = 0
|
|
|
+ show_progress(self, rebuild_count, posts_to_reindex)
|
|
|
start_time = time.time()
|
|
|
|
|
|
queryset = Post.objects.select_related('thread').filter(is_event=False)
|
|
@@ -39,7 +36,7 @@ class Command(BaseCommand):
|
|
|
post.update_search_vector()
|
|
|
post.save(update_fields=['search_vector'])
|
|
|
|
|
|
- synchronized_count += 1
|
|
|
- show_progress(self, synchronized_count, posts_to_sync, start_time)
|
|
|
+ rebuild_count += 1
|
|
|
+ show_progress(self, rebuild_count, posts_to_reindex, start_time)
|
|
|
|
|
|
- self.stdout.write(message % synchronized_count)
|
|
|
+ self.stdout.write("\n\nRebuild search for {} posts".format(rebuild_count))
|