<commit_before>from django.core.cache import cache
from django.contrib.messages import constants


def message_user(user, message, level=constants.INFO):
    """
    Send a message to a particular user.

    :param user: User instance
    :param message: Message to show
    :param level: Message level
    """
    # We store a list of messages in the cache so we can have multiple messages
    # queued up for a user.
    user_key = _user_key(user)
    messages = cache.get(user_key) or []
    messages.append((message, level))
    cache.set(user_key, messages)


def message_users(users, message, level=constants.INFO):
    """
    Send a message to a group of users.

    :param users: Users queryset
    :param message: Message to show
    :param level: Message level
    """
    for user in users:
        message_user(user, message, level)


def get_messages(user):
    """
    Fetch messages for given user.  Returns None if no such message exists.

    :param user: User instance
    """
    key = _user_key(user)
    result = cache.get(key)
    if result:
        cache.delete(key)
        return result
    return None


def _user_key(user):
    return '_async_message_%d' % user.id
<commit_msg>Fixed getting the primary key of the custom user model<commit_after>from django.core.cache import cache
from django.contrib.messages import constants


def message_user(user, message, level=constants.INFO):
    """
    Send a message to a particular user.

    :param user: User instance
    :param message: Message to show
    :param level: Message level
    """
    # We store a list of messages in the cache so we can have multiple messages
    # queued up for a user.
    user_key = _user_key(user)
    messages = cache.get(user_key) or []
    messages.append((message, level))
    cache.set(user_key, messages)


def message_users(users, message, level=constants.INFO):
    """
    Send a message to a group of users.

    :param users: Users queryset
    :param message: Message to show
    :param level: Message level
    """
    for user in users:
        message_user(user, message, level)


def get_messages(user):
    """
    Fetch messages for given user.  Returns None if no such message exists.

    :param user: User instance
    """
    key = _user_key(user)
    result = cache.get(key)
    if result:
        cache.delete(key)
        return result
    return None


def _user_key(user):
    return '_async_message_%d' % user.pk

{'fraction_non_alphanumeric': 0.0864953080375357, 'fraction_numerical': 0.0, 'mean_word_length': 2.942122186495177, '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': '742571', 'n_tokens_mistral': 720, 'n_tokens_neox': 707, 'n_words': 263}