<commit_before>
from logging import getLogger

from django.db.models.signals import pre_save, pre_delete
from django.dispatch import receiver

from dynamic_databases.models import Database


logger = getLogger('dynamic_databases.receivers')


@receiver([pre_save, pre_delete], sender=Database)
def unregister_database(sender, **kwargs):
    if 'instance' in kwargs:
        kwargs['instance'].unregister()
<commit_msg>Updated signal receiver to skip if the instance is new. New instances haven't been registered so don't need to be unregistered.<commit_after>
from logging import getLogger

from django.db.models.signals import pre_save, pre_delete
from django.dispatch import receiver

from dynamic_databases.models import Database


logger = getLogger('dynamic_databases.receivers')


@receiver([pre_save, pre_delete], sender=Database)
def unregister_database(sender, **kwargs):
    if 'instance' in kwargs and kwargs['instance'].pk is not None:
        kwargs['instance'].unregister()

{'fraction_non_alphanumeric': 0.08805668016194332, 'fraction_numerical': 0.0, 'mean_word_length': 5.916083916083916, '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': '6790250', 'n_tokens_mistral': 271, 'n_tokens_neox': 268, 'n_words': 87}