<commit_before>from celery.decorators import task
from models import Email

@task
def send(entry, **kwargs):
    logger = send.get_logger(**kwargs)
    logger.info("Sending entry: %s" % entry.title)
    emails = Email.objects.all()
    for em in emails:
        send_entry_to.delay(entry.title, title.summary, em.email)

@task
def send_entry_to(title, content, email):
    logger = add.get_logger(**kwargs)
    logger.info("Sending to: %s" % email)<commit_msg>Implementation of sending emails by batches.<commit_after>from celery.decorators import task
from django.core.mail import send_mail

from models import Email

@task
def send(entry, **kwargs):
    logger = send.get_logger(**kwargs)
    logger.info("Sending entry: %s" % entry.title)
    
    emails_all = Email.objects.all()
    step = 3  # how many recipients in one mail
    
    for i in range(0, len(emails_all), step):
        recipients = map(lambda e: e.email, emails_all[i:i+step])
        send_entry_to.delay(entry.title, entry.summary, recipients)

@task
def send_entry_to(title, body, recipients, **kwargs):
    logger = send.get_logger(**kwargs)
    logger.info("Sending to: %s" % ','.join(recipients))
    send_mail(title, body, "<EMAIL>", recipients) 
{'fraction_non_alphanumeric': 0.12908496732026145, 'fraction_numerical': 0.0016339869281045752, 'mean_word_length': 4.06198347107438, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6467272', 'n_tokens_mistral': 406, 'n_tokens_neox': 393, 'n_words': 104}