Separates erase and populate stream comands

This commit is contained in:
Mouse Reeve 2021-03-28 11:38:39 -07:00
parent b377c5bc22
commit 5441d4db09
2 changed files with 29 additions and 12 deletions

View file

@ -0,0 +1,23 @@
""" Delete user streams """
from django.core.management.base import BaseCommand
import redis
from bookwyrm import settings
r = redis.Redis(
host=settings.REDIS_ACTIVITY_HOST, port=settings.REDIS_ACTIVITY_PORT, db=0
)
def erase_streams():
""" throw the whole redis away """
r.flushall()
class Command(BaseCommand):
""" delete activity streams for all users """
help = "Delete all the user streams"
# pylint: disable=no-self-use,unused-argument
def handle(self, *args, **options):
""" flush all, baby """
erase_streams()

View file

@ -1,4 +1,4 @@
""" Delete and re-create user feeds """
""" Re-create user streams """
from django.core.management.base import BaseCommand
import redis
@ -9,13 +9,8 @@ r = redis.Redis(
)
def erase_feeds():
""" throw the whole redis away """
r.flushall()
def create_feeds():
""" build all the fields for all the users """
def populate_streams():
""" build all the streams for all the users """
users = models.User.objects.filter(
local=True,
is_active=True,
@ -26,11 +21,10 @@ def create_feeds():
class Command(BaseCommand):
""" start all over with user feeds """
""" start all over with user streams """
help = "Delete and re-create all the user feeds"
help = "Populate streams for all users"
# pylint: disable=no-self-use,unused-argument
def handle(self, *args, **options):
""" run feed builder """
erase_feeds()
create_feeds()
populate_streams()