diff --git a/activities/management/commands/pruneposts.py b/activities/management/commands/pruneposts.py index 19b8ea3..287d48d 100644 --- a/activities/management/commands/pruneposts.py +++ b/activities/management/commands/pruneposts.py @@ -73,10 +73,11 @@ class Command(BaseCommand): # Delete them if not final_post_ids: - sys.exit(1) + sys.exit(0) print("Deleting...") _, deleted = Post.objects.filter(id__in=final_post_ids).delete() print("Deleted:") for model, model_deleted in deleted.items(): print(f" {model}: {model_deleted}") + sys.exit(1) diff --git a/docs/tuning.rst b/docs/tuning.rst index 73cc616..d10f0b3 100644 --- a/docs/tuning.rst +++ b/docs/tuning.rst @@ -128,11 +128,11 @@ Identity pruning removes any identity that isn't: * A liker or booster of a local post We recommend you run the pruning commands on a scheduled basis (i.e. like -a cronjob). They will return a ``0`` exit code if they deleted something and -a ``1`` exit code if they found nothing to delete, if you want to put them in +a cronjob). They will return a ``1`` exit code if they deleted something and +a ``0`` exit code if they found nothing to delete, if you want to put them in a loop that runs until deletion is complete:: - while ./manage.py pruneposts; do sleep 1; done + until ./manage.py pruneposts; do sleep 1; done Caching diff --git a/users/management/commands/pruneidentities.py b/users/management/commands/pruneidentities.py index f791ce1..c93f1fa 100644 --- a/users/management/commands/pruneidentities.py +++ b/users/management/commands/pruneidentities.py @@ -43,7 +43,7 @@ class Command(BaseCommand): identity_ids = identities.values_list("id", flat=True) print(f" found {len(identity_ids)}") if not identity_ids: - sys.exit(1) + sys.exit(0) # Delete them print("Deleting...") @@ -51,3 +51,4 @@ class Command(BaseCommand): print("Deleted:") for model, model_deleted in deleted.items(): print(f" {model}: {model_deleted}") + sys.exit(1)