From eb0b0d775cdeafc4972e0a3cba94ddeb1e6d8a9a Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 12 Nov 2023 18:06:29 -0700 Subject: [PATCH] Don't delete mentioned people --- activities/management/commands/pruneposts.py | 11 +++++------ users/management/commands/pruneidentities.py | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/activities/management/commands/pruneposts.py b/activities/management/commands/pruneposts.py index 8c3667c..7ae34ba 100644 --- a/activities/management/commands/pruneposts.py +++ b/activities/management/commands/pruneposts.py @@ -51,13 +51,12 @@ class Command(BaseCommand): del post_ids_and_uris[reply] # Delete them - print(f" down to {len(post_ids_and_uris)} to delete") + print(f" narrowed down to {len(post_ids_and_uris)}") + if not post_ids_and_uris: + sys.exit(1) + print("Deleting...") - number_deleted, deleted = Post.objects.filter( - id__in=post_ids_and_uris.values() - ).delete() + _, deleted = Post.objects.filter(id__in=post_ids_and_uris.values()).delete() print("Deleted:") for model, model_deleted in deleted.items(): print(f" {model}: {model_deleted}") - if number_deleted == 0: - sys.exit(1) diff --git a/users/management/commands/pruneidentities.py b/users/management/commands/pruneidentities.py index 7bf0a55..2e69ca8 100644 --- a/users/management/commands/pruneidentities.py +++ b/users/management/commands/pruneidentities.py @@ -32,6 +32,7 @@ class Command(BaseCommand): ).exclude( Q(interactions__post__local=True) | Q(posts__isnull=False) + | Q(posts_mentioning__isnull=False) | Q(outbound_follows__isnull=False) | Q(inbound_follows__isnull=False) | Q(outbound_blocks__isnull=False) @@ -41,6 +42,8 @@ class Command(BaseCommand): ] identity_ids = identities.values_list("id", flat=True) print(f" found {len(identity_ids)}") + if not identity_ids: + sys.exit(1) # Delete them print("Deleting...") @@ -48,5 +51,3 @@ class Command(BaseCommand): print("Deleted:") for model, model_deleted in deleted.items(): print(f" {model}: {model_deleted}") - if number_deleted == 0: - sys.exit(1)