Просмотр исходного кода

Resync all threads after fake posts creation ends

rafalp 6 лет назад
Родитель
Сommit
1014b3838b
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      misago/faker/management/commands/createfakeposts.py

+ 5 - 3
misago/faker/management/commands/createfakeposts.py

@@ -7,6 +7,7 @@ from faker import Factory
 
 from ....categories.models import Category
 from ....core.management.progressbar import show_progress
+from ....core.pgutils import chunk_queryset
 from ....threads.models import Thread
 from ...posts import get_fake_hidden_post, get_fake_post, get_fake_unapproved_post
 
@@ -58,12 +59,13 @@ class Command(BaseCommand):
             else:
                 get_fake_post(fake, thread, poster)
 
-            thread.synchronize()
-            thread.save()
-
             created_posts += 1
             show_progress(self, created_posts, items_to_create, start_time)
 
+        for thread in chunk_queryset(Thread.objects.all()):
+            thread.synchronize()
+            thread.save()
+
         for category in Category.objects.all():
             category.synchronize()
             category.save()