<commit_before>from rapidsms_httprouter.models import Message
from rapidsms.models import Connection
from unregister.models import Blacklist

def broadcast(text):
    """
    Schedule a one-off message for every non-blacklisted connection.
    """
    for connection in Connection.objects.all(): 
        if not Blacklist.objects.filter(connection = connection).exists():
            Message.objects.create(connection = connection, text = text, direction='O', status='Q')<commit_msg>[Emily, Chris] Use a standard API method rather than rolling our own to decrease the chances of incompatibility.<commit_after>from rapidsms_httprouter.models import Message
from rapidsms.models import Connection
from unregister.models import Blacklist

def broadcast(text):
    """
    Schedule a one-off message for every non-blacklisted connection.
    """
    connections = [c for c in Connection.objects.all() if not Blacklist.objects.filter(connection=c).exists()]
    Message.mass_text(text, connections)
{'fraction_non_alphanumeric': 0.08862034239677745, 'fraction_numerical': 0.0, 'mean_word_length': 4.584269662921348, 'pattern_counts': {'":': 0, '<': 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': '4964532', 'n_tokens_mistral': 251, 'n_tokens_neox': 251, 'n_words': 85}