mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Management command for rebuilding ALL feeds
This commit is contained in:
parent
02bd94fdc8
commit
1fa7330595
1 changed files with 34 additions and 0 deletions
34
bookwyrm/management/commands/rebuild_feeds.py
Normal file
34
bookwyrm/management/commands/rebuild_feeds.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
""" Delete and re-create user feeds """
|
||||
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
|
||||
)
|
||||
|
||||
def erase_feeds():
|
||||
""" throw the whole redis away """
|
||||
r.flushall()
|
||||
|
||||
def create_feeds():
|
||||
""" build all the fields for all the users """
|
||||
users = models.User.objects.filter(
|
||||
local=True,
|
||||
is_active=True,
|
||||
)
|
||||
for user in users:
|
||||
for stream in activitystreams.streams.values():
|
||||
stream.populate_stream(user)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
""" start all over with user feeds """
|
||||
|
||||
help = "Delete and re-create all the user feeds"
|
||||
# pylint: disable=no-self-use,unused-argument
|
||||
def handle(self, *args, **options):
|
||||
""" run feed builder """
|
||||
erase_feeds()
|
||||
create_feeds()
|
Loading…
Reference in a new issue