<commit_before>from datetime import timedelta

from django.core.mail import mail_admins
from django.core.management.base import BaseCommand
from django.template import loader
from django.utils.timezone import now

from cl.stats.models import Event


class Command(BaseCommand):
    help = 'Send an email to the admins with any events from the past day.'

    def handle(self, *args, **options):
        today = now()
        yesterday = today - timedelta(days=1)
        events = Event.objects.filter(date_created__gte=yesterday)
        if events.count() > 0:
            template = loader.get_template('emails/events_email.txt')
            txt = template.render({'events': events})
            mail_admins(
                'CourtListener events email for %s' % today.date().isoformat(),
                txt,
            )<commit_msg>Tweak.<commit_after>from datetime import timedelta

from django.core.mail import mail_admins
from django.core.management.base import BaseCommand
from django.template import loader
from django.utils.timezone import now

from cl.stats.models import Event


class Command(BaseCommand):
    help = 'Send an email to the admins with any events from the past day.'

    def handle(self, *args, **options):
        today = now()
        yesterday = today - timedelta(days=1)
        events = Event.objects.filter(date_created__gte=yesterday)
        if events.count() > 0:
            template = loader.get_template('emails/events_email.txt')
            mail_admins(
                'CourtListener events email for %s' % today.date().isoformat(),
                template.render({'events': events}),
            )
{'fraction_non_alphanumeric': 0.09494826536822885, 'fraction_numerical': 0.002434570906877663, 'mean_word_length': 2.8143851508120648, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2134354', 'n_tokens_mistral': 458, 'n_tokens_neox': 440, 'n_words': 132}