<commit_before>from django.db.models.signals import (
    post_save,
)

from django.dispatch import receiver

from .models import (
    Performance,
    Session,
)


@receiver(post_save, sender=Performance)
def performance_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create sentinels."""
    if not raw:
        if created:
            s = 1
            while s <= instance.round.num_songs:
                song = instance.songs.create(
                    performance=instance,
                    num=s,
                )
                s += 1
                judges = instance.round.session.judges.filter(
                    category__in=[
                        instance.round.session.judges.model.CATEGORY.music,
                        instance.round.session.judges.model.CATEGORY.presentation,
                        instance.round.session.judges.model.CATEGORY.singing,
                    ]
                )
                for judge in judges:
                    judge.scores.create(
                        judge=judge,
                        song=song,
                        category=judge.category,
                        kind=judge.kind,
                    )


@receiver(post_save, sender=Session)
def session_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create sentinels."""
    if not raw:
        if created:
            i = 1
            while i <= instance.num_rounds:
                instance.rounds.create(
                    num=i,
                    kind=(instance.num_rounds - i) + 1,
                )
                i += 1<commit_msg>Create sentinel rounds on Session creation<commit_after>from django.db.models.signals import (
    post_save,
)

from django.dispatch import receiver

from .models import (
    Performance,
    Session,
)


@receiver(post_save, sender=Session)
def session_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create sentinels."""
    if not raw:
        if created:
            i = 1
            while i <= instance.num_rounds:
                instance.rounds.create(
                    num=i,
                    kind=(instance.num_rounds - i) + 1,
                )
                i += 1


@receiver(post_save, sender=Performance)
def performance_post_save(sender, instance=None, created=False, raw=False, **kwargs):
    """Create sentinels."""
    if not raw:
        if created:
            s = 1
            while s <= instance.round.num_songs:
                song = instance.songs.create(
                    performance=instance,
                    num=s,
                )
                s += 1
                judges = instance.round.session.judges.filter(
                    category__in=[
                        instance.round.session.judges.model.CATEGORY.music,
                        instance.round.session.judges.model.CATEGORY.presentation,
                        instance.round.session.judges.model.CATEGORY.singing,
                    ]
                )
                for judge in judges:
                    judge.scores.create(
                        judge=judge,
                        song=song,
                        category=judge.category,
                        kind=judge.kind,
                    )
{'fraction_non_alphanumeric': 0.09071666162685213, 'fraction_numerical': 0.0030238887208950713, 'mean_word_length': 1.3165266106442577, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4411242', 'n_tokens_mistral': 902, 'n_tokens_neox': 818, 'n_words': 166}