<commit_before>from celery import shared_task

from .models import Email
from .utils import EmailServer


@shared_task
def send_unsent_emails():
    emails = Email.objects.filter(is_sent=False)
    email_server = EmailServer()
    for email in emails:
        email_server.send_email(email.recipient, email.body, email.subject)
        email.is_sent = True
        email.save()

    email_server.tear_down()<commit_msg>Only send emails on PROD<commit_after>from celery import shared_task

from django.conf import settings

from .models import Email
from .utils import EmailServer


@shared_task
def send_unsent_emails():
    emails = Email.objects.filter(is_sent=False)
    if settings.ENV != "DEV":
        email_server = EmailServer()

    for email in emails:
        if settings.ENV != "DEV":
            email_server.send_email(email.recipient, email.body, email.subject)

        email.is_sent = True
        email.save()

    if settings.ENV != "DEV":
        email_server.tear_down()

{'fraction_non_alphanumeric': 0.08971774193548387, 'fraction_numerical': 0.0, 'mean_word_length': 3.2987012987012987, 'pattern_counts': {'":': 3, '<': 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': '7342020', 'n_tokens_mistral': 305, 'n_tokens_neox': 296, 'n_words': 76}