2021-12-30 01:39:14 +00:00
|
|
|
""" Re-create list streams """
|
2021-11-16 18:41:08 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from bookwyrm import lists_stream, models
|
|
|
|
|
|
|
|
|
|
|
|
def populate_lists_streams():
|
|
|
|
"""build all the lists streams for all the users"""
|
|
|
|
print("Populating lists streams")
|
|
|
|
users = models.User.objects.filter(
|
|
|
|
local=True,
|
|
|
|
is_active=True,
|
|
|
|
).order_by("-last_active_date")
|
|
|
|
print("This may take a long time! Please be patient.")
|
|
|
|
for user in users:
|
|
|
|
print(".", end="")
|
2021-12-10 17:34:17 +00:00
|
|
|
lists_stream.populate_lists_task.delay(user.id)
|
2022-01-09 11:11:52 +00:00
|
|
|
print("\nAll done, thank you for your patience!")
|
2021-11-16 18:41:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2021-12-30 01:39:14 +00:00
|
|
|
"""start all over with lists streams"""
|
2021-11-16 18:41:08 +00:00
|
|
|
|
2021-12-30 01:39:14 +00:00
|
|
|
help = "Populate list streams for all users"
|
2021-11-16 18:41:08 +00:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument(
|
|
|
|
"--stream",
|
|
|
|
default=None,
|
|
|
|
help="Specifies which time of stream to populate",
|
|
|
|
)
|
|
|
|
|
|
|
|
# pylint: disable=no-self-use,unused-argument
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
"""run feed builder"""
|
|
|
|
populate_lists_streams()
|