<commit_before># Django
from auth0.v2.management import Auth0
from django.conf import settings
from django.db import transaction
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.core.mail import send_mail

# Local
from .models import (
    Award,
    Session,
    User,
    Contest,
    ContestPrivate,
    Performer,
    PerformerPrivate,
    Performance,
    PerformancePrivate,
    Song,
    SongPrivate,
    Contestant,
    ContestantPrivate,
)


@receiver(post_save, sender=Session)
def session_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create sentinels."""
    if not raw:
        if created:
            with transaction.atomic():

                # Add Rounds
                i = 1
                while i <= instance.num_rounds:
                    instance.rounds.create(
                        num=i,
                        kind=(instance.num_rounds - i) + 1,
                    )
                    i += 1
                # Add Contests
                awards = Award.objects.filter(
                    entity__hosts__convention=instance.convention,
                    status=Award.STATUS.active,
                    kind=instance.kind,
                )
                # Add all direct championship awards
                for award in awards:
                    instance.contests.create(
                        award=award,
                        num_rounds=award.championship_rounds
                    )
                # Add Prelims (if necessary)
                # Check if it's a prelim session
                if instance.is_prelims:
                    # Get the "highest" host, excluding the Divisions
                    host = instance.convention.hosts.filter(
                        entity__kind__lt=20,
                        entity__status=10,
                    ).order_by(
                        'entity__kind',
                    ).first()
                    # Find the primary award of that host entity
                    prelim = host.entity.parent.awards.get(
                        is_primary=True,
                        kind=instance.kind,
                    )
                    instance.contests.create(
                        award=prelim,
                        num_rounds=prelim.qualifier_rounds,
                        is_qualifier=True,
                    )


@receiver(post_save, sender=Contest)
def contest_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create Private Contest."""
    if not raw:<commit_msg>Disable overly aggressive Session signal<commit_after># Django
from auth0.v2.management import Auth0
from django.conf import settings
from django.db import transaction
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.core.mail import send_mail

# Local
from .models import (
    Award,
    Session,
    User,
    Contest,
    ContestPrivate,
    Performer,
    PerformerPrivate,
    Performance,
    PerformancePrivate,
    Song,
    SongPrivate,
    Contestant,
    ContestantPrivate,
)


@receiver(post_save, sender=Session)
def session_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create sentinels."""
    if not raw:
        if created:
            with transaction.atomic():

                # Add Rounds
                i = 1
                while i <= instance.num_rounds:
                    instance.rounds.create(
                        num=i,
                        kind=(instance.num_rounds - i) + 1,
                    )
                    i += 1
                # # Add Contests
                # awards = Award.objects.filter(
                #     entity__hosts__convention=instance.convention,
                #     status=Award.STATUS.active,
                #     kind=instance.kind,
                # )
                # # Add all direct championship awards
                # for award in awards:
                #     instance.contests.create(
                #         award=award,
                #         num_rounds=award.championship_rounds
                #     )
                # # Add Prelims (if necessary)
                # # Check if it's a prelim session
                # if instance.is_prelims:
                #     # Get the "highest" host, excluding the Divisions
                #     host = instance.convention.hosts.filter(
                #         entity__kind__lt=20,
                #         entity__status=10,
                #     ).order_by(
                #         'entity__kind',
                #     ).first()
                #     # Find the primary award of that host entity
                #     prelim = host.entity.parent.awards.get(
                #         is_primary=True,
                #         kind=instance.kind,
                #     )
                #     instance.contests.create(
                #         award=prelim,
                #         num_rounds=prelim.qualifier_rounds,
                #         is_qualifier=True,
                #     )


@receiver(post_save, sender=Contest)
def contest_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create Private Contest."""
    if not raw:
{'fraction_non_alphanumeric': 0.07705446953881191, 'fraction_numerical': 0.0037957866767887646, 'mean_word_length': 1.3328906595838867, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3673517', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1277, 'n_words': 301}