Merge pull request #809 from mouse-reeve/stream-commands

Separates erase and populate stream commands
This commit is contained in:
Mouse Reeve 2021-03-28 12:04:51 -07:00 committed by GitHub
commit 1e8444a622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 13 deletions

View file

@ -0,0 +1,24 @@
""" 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()

5
bw-dev
View file

@ -109,7 +109,10 @@ case "$CMD" in
black)
makeitblack
;;
populate_feeds)
execweb python manage.py populate_streams
;;
*)
echo "Unrecognised command. Try: build, clean, up, initdb, resetdb, makemigrations, migrate, bash, shell, dbshell, restart_celery, test, pytest, test_report, black"
echo "Unrecognised command. Try: build, clean, up, initdb, resetdb, makemigrations, migrate, bash, shell, dbshell, restart_celery, test, pytest, test_report, black, populate_feeds"
;;
esac