<commit_before>import os
import json
import logging

from random import shuffle
from sqlalchemy import and_, func
from uuid import uuid4

from newparp.model import Block, ChatUser, Message, User

option_messages = {
    "script": "This is a script style chat.",
    "paragraph": "This is a paragraph style chat.",
    "sfw": "Please keep this chat safe for work.",
    "nsfw": "NSFW content is allowed.",
    "nsfw-extreme": "Extreme NSFW content is allowed.",
    "roulette": "TT: There is a 98.413% chance that you have just connected to someone anonymously. It seems that you should probably say \"Hello\" now.",
}


def wake_unmatched_searchers(redis, searcher_prefix, searcher_ids):
    for searcher in searcher_ids:
        logging.debug("Waking unmatched searcher %s." % searcher)
        redis.publish("%s:%s" % (searcher_prefix, searcher), "{ \"status\": \"unmatched\" }")


def run_matchmaker(
    db, redis, lock_id, searchers_key, searcher_prefix, get_searcher_info,
    check_compatibility, ChatClass, get_character_info
):

    root = logging.getLogger()
    if 'DEBUG' in os.environ:
        root.setLevel(logging.DEBUG)

    searcher_ids = redis.smembers(searchers_key)

    # Reset the searcher list for the next iteration.
    redis.delete(searchers_key)

    logging.info("Starting match loop.")

    # We can't do anything with less than 2 people, so don't bother.
    if len(searcher_ids) < 2:
        logging.info("Not enough searchers, skipping.")
        wake_unmatched_searchers(redis, searcher_prefix, searcher_ids)
        return

    searchers = get_searcher_info(redis, searcher_ids)
    logging.debug("Searcher list: %s" % searchers)
    shuffle(searchers)

    already_matched = set()
    # Range hack so we don't check opposite pairs or against itself.
    for n in range(len(searchers)):
        s1 = searchers[n]

        for m in range(n + 1, len(searchers)):
            s2 = searchers[m]

            if s1["id"] in already_matched or s2["id"] in already_matched:
                continue
<commit_msg>Change the level of match loop messages to debug.<commit_after>import os
import json
import logging

from random import shuffle
from sqlalchemy import and_, func
from uuid import uuid4

from newparp.model import Block, ChatUser, Message, User

option_messages = {
    "script": "This is a script style chat.",
    "paragraph": "This is a paragraph style chat.",
    "sfw": "Please keep this chat safe for work.",
    "nsfw": "NSFW content is allowed.",
    "nsfw-extreme": "Extreme NSFW content is allowed.",
    "roulette": "TT: There is a 98.413% chance that you have just connected to someone anonymously. It seems that you should probably say \"Hello\" now.",
}


def wake_unmatched_searchers(redis, searcher_prefix, searcher_ids):
    for searcher in searcher_ids:
        logging.debug("Waking unmatched searcher %s." % searcher)
        redis.publish("%s:%s" % (searcher_prefix, searcher), "{ \"status\": \"unmatched\" }")


def run_matchmaker(
    db, redis, lock_id, searchers_key, searcher_prefix, get_searcher_info,
    check_compatibility, ChatClass, get_character_info
):

    root = logging.getLogger()
    if 'DEBUG' in os.environ:
        root.setLevel(logging.DEBUG)

    searcher_ids = redis.smembers(searchers_key)

    # Reset the searcher list for the next iteration.
    redis.delete(searchers_key)

    logging.debug("Starting match loop.")

    # We can't do anything with less than 2 people, so don't bother.
    if len(searcher_ids) < 2:
        logging.debug("Not enough searchers, skipping.")
        wake_unmatched_searchers(redis, searcher_prefix, searcher_ids)
        return

    searchers = get_searcher_info(redis, searcher_ids)
    logging.debug("Searcher list: %s" % searchers)
    shuffle(searchers)

    already_matched = set()
    # Range hack so we don't check opposite pairs or against itself.
    for n in range(len(searchers)):
        s1 = searchers[n]

        for m in range(n + 1, len(searchers)):
            s2 = searchers[m]

            if s1["id"] in already_matched or s2["id"] in already_matched:
                continue

{'fraction_non_alphanumeric': 0.1008750607681089, 'fraction_numerical': 0.006319883325230919, 'mean_word_length': 3.3683651804670913, 'pattern_counts': {'":': 14, '<': 5, '<?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': '5874303', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1302, 'n_words': 410}