mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Merge pull request #809 from mouse-reeve/stream-commands
Separates erase and populate stream commands
This commit is contained in:
commit
1e8444a622
3 changed files with 34 additions and 13 deletions
24
bookwyrm/management/commands/erase_streams.py
Normal file
24
bookwyrm/management/commands/erase_streams.py
Normal 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()
|
|
@ -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
5
bw-dev
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue