<commit_before>

# Standard Library
from collections import defaultdict

# Third-Party
import django_rq

# Django
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.db.models.signals import pre_delete
from django.db.models.signals import post_save
from django.dispatch import receiver

# Local
from .models import Person
from .models import User



@receiver(post_save, sender=Person)
def person_post_save(sender, instance, created, **kwargs):
    if created and instance.email:
        User.objects.create_user(person=instance)
    user = getattr(instance, 'user', None)
    if user and instance.tracker.has_changed('email'):
        queue = django_rq.get_queue('low')
        if instance.email:
            queue.enqueue(
                instance.user.update_account,
            )
        else:
            queue.enqueue(
                instance.user.delete_account,
            )
    return


@receiver(pre_delete, sender=User)
def user_pre_delete(sender, instance, **kwargs):
    if not instance.is_staff:
        queue = django_rq.get_queue('low')
        queue.enqueue(
            instance.delete_account
        )
    return<commit_msg>Remove tuple<commit_after>

# Standard Library
from collections import defaultdict

# Third-Party
import django_rq

# Django
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.db.models.signals import pre_delete
from django.db.models.signals import post_save
from django.dispatch import receiver

# Local
from .models import Person
from .models import User



@receiver(post_save, sender=Person)
def person_post_save(sender, instance, created, **kwargs):
    if created and instance.email:
        User.objects.create_user(person=instance)
    user = getattr(instance, 'user', None)
    if user and instance.tracker.has_changed('email'):
        queue = django_rq.get_queue('low')
        if instance.email:
            queue.enqueue(
                instance.user.update_account
            )
        else:
            queue.enqueue(
                instance.user.delete_account
            )
    return


@receiver(pre_delete, sender=User)
def user_pre_delete(sender, instance, **kwargs):
    if not instance.is_staff:
        queue = django_rq.get_queue('low')
        queue.enqueue(
            instance.delete_account
        )
    return
{'fraction_non_alphanumeric': 0.08067769261799113, 'fraction_numerical': 0.0, 'mean_word_length': 2.987138263665595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4001020', 'n_tokens_mistral': 696, 'n_tokens_neox': 679, 'n_words': 176}