<commit_before>import random
from collections import defaultdict
from optparse import make_option

from django.contrib.auth.models import User
from django.core.management.base import BaseCommand

from symposion.reviews.models import ProposalGroup, ReviewAssignment
from symposion.utils.mail import send_email


class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option(
            "--proposal-group-name",
            help="Which proposal group to assign reviewers for",
        ),
    )

    def handle(self, *args, **options):
        group = ProposalGroup.objects.get(
            name=options["proposal_group_name"],
        )
        reviewers = list(User.objects.filter(
            group__name="reviewers",
        ))
        user_reviews = defaultdict(list)
        for proposal_result in group.proposal_results.all():
            proposal_reviewers = random.sample([
                user for user in reviewers
                if user.id not in self.proposal_speaker_user_ids(proposal_result.proposal)
            ], 7)
            for reviewer in proposal_reviewers:
                user_reviews[reviewer].append(proposal_result)

        for user, proposal_results in user_reviews.iteritems():
            for pr in proposal_results:
                ReviewAssignment.objects.create(
                    proposal=pr.proposal,
                    user=user,
                    origin=ReviewAssignment.AUTO_ASSIGNED_INITIAL,
                )
            send_email([user.email], "new_review_assignments", context={
                "user": user,
                "proposal_results": proposal_results,
                "proposal_group": group,
            })
<commit_msg>Fixed a typo that snuck in<commit_after>import random
from collections import defaultdict
from optparse import make_option

from django.contrib.auth.models import User
from django.core.management.base import BaseCommand

from symposion.reviews.models import ProposalGroup, ReviewAssignment
from symposion.utils.mail import send_email


class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option(
            "--proposal-group-name",
            help="Which proposal group to assign reviewers for",
        ),
    )

    def handle(self, *args, **options):
        group = ProposalGroup.objects.get(
            name=options["proposal_group_name"],
        )
        reviewers = list(User.objects.filter(
            groups__name="reviewers",
        ))
        user_reviews = defaultdict(list)
        for proposal_result in group.proposal_results.all():
            proposal_reviewers = random.sample([
                user for user in reviewers
                if user.id not in self.proposal_speaker_user_ids(proposal_result.proposal)
            ], 7)
            for reviewer in proposal_reviewers:
                user_reviews[reviewer].append(proposal_result)

        for user, proposal_results in user_reviews.iteritems():
            for pr in proposal_results:
                ReviewAssignment.objects.create(
                    proposal=pr.proposal,
                    user=user,
                    origin=ReviewAssignment.AUTO_ASSIGNED_INITIAL,
                )
            send_email([user.email], "new_review_assignments", context={
                "user": user,
                "proposal_results": proposal_results,
                "proposal_group": group,
            })

{'fraction_non_alphanumeric': 0.07790697674418605, 'fraction_numerical': 0.0005813953488372093, 'mean_word_length': 2.1685082872928176, 'pattern_counts': {'":': 6, '<': 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': '5214535', 'n_tokens_mistral': 902, 'n_tokens_neox': 875, 'n_words': 197}