Don't delete mentioned people

This commit is contained in:
Andrew Godwin 2023-11-12 18:06:29 -07:00
parent 74f69a3813
commit eb0b0d775c
2 changed files with 8 additions and 8 deletions

View file

@ -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)

View file

@ -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)