<commit_before># https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/

from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

from toolkit.members.models import Member


class Command(BaseCommand):
    help = "Delete non-members who don't get the members mailout"

    def handle(self, *args, **options):

        dead_wood = (Member.objects.filter(email__isnull=False)
                                   .exclude(email='')
                                   .exclude(mailout_failed=True)
                                   .exclude(mailout=True)
                                   .exclude(is_member=True)
                     )

        self.stdout.write('Deleting...')

        for member in dead_wood:
            self.stdout.write('%s <%s> joined %s' % (
                member.name,
                member.email,
                member.created_at)
            )
        # member.delete()

        self.stdout.write(self.style.SUCCESS(
            '\nDeleted %d non-members\n' % len(dead_wood)))<commit_msg>Corrected delete_non_members_who_dont_get_the_mailout so that it actually deletes the members<commit_after># https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/

from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

from toolkit.members.models import Member


class Command(BaseCommand):
    help = "Delete non-members who don't get the members mailout"

    def handle(self, *args, **options):

        dead_wood = (Member.objects.filter(email__isnull=False)
                                   .exclude(email='')
                                   .exclude(mailout_failed=True)
                                   .exclude(mailout=True)
                                   .exclude(is_member=True)
                     )

        self.stdout.write('Deleting...')

        for member in dead_wood:
            self.stdout.write('%s <%s> joined %s' % (
                member.name,
                member.email,
                member.created_at)
            )
            member.delete()

        self.stdout.write(self.style.SUCCESS(
            '\nDeleted %d non-members\n' % len(dead_wood)))
{'fraction_non_alphanumeric': 0.10330948121645796, 'fraction_numerical': 0.0026833631484794273, 'mean_word_length': 1.7148058252427185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '985737', 'n_tokens_mistral': 635, 'n_tokens_neox': 591, 'n_words': 115}