<commit_before>import logging
from collections import defaultdict
from datetime import datetime
from datetime import timedelta

from database import db
from yelp_beans.logic.config import get_config
from yelp_beans.models import Meeting
from yelp_beans.models import MeetingParticipant
from yelp_beans.models import MeetingSpec


def save_meetings(matches, spec):
    for match in matches:
        # Last element in match is the key for meeting time
        matched_users = match[:-1]
        meeting_key = Meeting(meeting_spec=spec)
        db.session.add(meeting_key)
        for user in matched_users:
            mp = MeetingParticipant(meeting=meeting_key, user=user)
            db.session.add(mp)
        db.session.commit()
        username_list = [user.get_username() for user in matched_users]
        logging.info(meeting_key)
        logging.info(', '.join(username_list))


def get_counts_for_pairs(pairs):
    counts = {}
    for pair in pairs:
        if pair in counts:
            counts[pair] += 1
        else:
            counts[pair] = 1
    return counts


def get_previous_meetings(subscription, cooldown=None):

    if cooldown is None:
        cooldown = get_config()['meeting_cooldown_weeks']

    meetings = defaultdict(list)
<commit_msg>Handle group matches not including time in the list<commit_after>import logging
from collections import defaultdict
from datetime import datetime
from datetime import timedelta

from database import db
from yelp_beans.logic.config import get_config
from yelp_beans.models import Meeting
from yelp_beans.models import MeetingParticipant
from yelp_beans.models import MeetingSpec
from yelp_beans.models import User


def save_meetings(matches, spec):
    for match in matches:
        # Last element in match may be the key for meeting time
        matched_users = [user for user in match if isinstance(user, User)]
        meeting_key = Meeting(meeting_spec=spec)
        db.session.add(meeting_key)
        for user in matched_users:
            mp = MeetingParticipant(meeting=meeting_key, user=user)
            db.session.add(mp)
        db.session.commit()
        username_list = [user.get_username() for user in matched_users]
        logging.info(meeting_key)
        logging.info(', '.join(username_list))


def get_counts_for_pairs(pairs):
    counts = {}
    for pair in pairs:
        if pair in counts:
            counts[pair] += 1
        else:
            counts[pair] = 1
    return counts


def get_previous_meetings(subscription, cooldown=None):

    if cooldown is None:
        cooldown = get_config()['meeting_cooldown_weeks']

    meetings = defaultdict(list)

{'fraction_non_alphanumeric': 0.0702682281828485, 'fraction_numerical': 0.0018889308651303363, 'mean_word_length': 3.1700787401574804, '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': '4317201', 'n_tokens_mistral': 783, 'n_tokens_neox': 757, 'n_words': 226}