2021-03-28 18:38:39 +00:00
|
|
|
""" Re-create user streams """
|
2021-03-23 20:23:35 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
import redis
|
|
|
|
|
|
|
|
from bookwyrm import activitystreams, models, settings
|
|
|
|
|
|
|
|
r = redis.Redis(
|
|
|
|
host=settings.REDIS_ACTIVITY_HOST, port=settings.REDIS_ACTIVITY_PORT, db=0
|
|
|
|
)
|
|
|
|
|
2021-03-23 20:28:05 +00:00
|
|
|
|
2021-03-28 18:38:39 +00:00
|
|
|
def populate_streams():
|
2021-04-26 16:15:42 +00:00
|
|
|
"""build all the streams for all the users"""
|
2021-03-23 20:23:35 +00:00
|
|
|
users = models.User.objects.filter(
|
|
|
|
local=True,
|
|
|
|
is_active=True,
|
|
|
|
)
|
|
|
|
for user in users:
|
|
|
|
for stream in activitystreams.streams.values():
|
2021-04-15 17:29:56 +00:00
|
|
|
stream.populate_streams(user)
|
2021-03-23 20:23:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2021-04-26 16:15:42 +00:00
|
|
|
"""start all over with user streams"""
|
2021-03-23 20:23:35 +00:00
|
|
|
|
2021-03-28 18:38:39 +00:00
|
|
|
help = "Populate streams for all users"
|
2021-03-23 20:23:35 +00:00
|
|
|
# pylint: disable=no-self-use,unused-argument
|
|
|
|
def handle(self, *args, **options):
|
2021-04-26 16:15:42 +00:00
|
|
|
"""run feed builder"""
|
2021-03-28 18:38:39 +00:00
|
|
|
populate_streams()
|