<commit_before>const PFSequelize = require('./PFSequelize.js');

const DEFAULT_TIME_OUT = 15 * 60; // 15 minutes
const DEFAULT_REFRESH_PERIOD = 1 * 60 // 1 minute

const TYPE_LFG = 'lfg';
const TYPE_LFM = 'lfm';

const ROLE_SPEC = {
    'attack': {
        name: 'Attacker',
        regex: /attack/i
    },

    'break': {
        name: 'Breaker',
        regex: /break/i
    },

    'defend': {
        name: 'Defender',
        regex: /defend/i
    },

    'support': {
        name: 'Support',
        regex: /support/i
    }
}

module.exports = class PartyFinder {

    /**
     * 
     * @param {Sequelize} sequelizeClient
     */
    constructor(sequelizeClient) {
        this.db = new PFSequelize(sequelizeClient);
        const db = this.db;
        this.monitoredChannels = {};
        const monitoredChannels = this.monitoredChannels;

        this.partyMemberDB = {};
        this.roleSpecs = ROLE_SPEC;
        this.TYPE_LFG = TYPE_LFG;
        this.TYPE_LFM = TYPE_LFM;

        db.init()
            .then(() => {
                return db.fetchAllChannel();
            })
            .then((channelList) => {
                channelList.forEach((channel) => monitoredChannels[channel.channel] = channel);
            })
            .catch((err) => {
                console.error('Unable to initialize party finder database', err);
                throw err;
            });
    }<commit_msg>WIP party channel<commit_after>const PFSequelize = require('./PFSequelize.js');

const DEFAULT_TIME_OUT = 15 * 60; // 15 minutes
const DEFAULT_REFRESH_PERIOD = 1 * 60 // 1 minute

const TYPE_LFG = 'lfg';
const TYPE_LFM = 'lfm';

const ROLE_SPEC = {
    'attack': {
        name: 'Attacker',
        regex: /attack/i
    },

    'break': {
        name: 'Breaker',
        regex: /break/i
    },

    'defend': {
        name: 'Defender',
        regex: /defend/i
    },

    'support': {
        name: 'Support',
        regex: /support/i
    }
}

module.exports = class PartyFinder {

    /**
     * 
     * @param {Sequelize} sequelizeClient
     */
    constructor(sequelizeClient) {
        this.db = new PFSequelize(sequelizeClient);
        const db = this.db;
        this.monitoredChannels = {};
        const monitoredChannels = this.monitoredChannels;

        this.partyMemberDB = {};
        this.monitoredPartyChannels = {};
        this.roleSpecs = ROLE_SPEC;
        this.TYPE_LFG = TYPE_LFG;
        this.TYPE_LFM = TYPE_LFM;

        db.init()
            .then(() => {
                return db.fetchAllChannel();
            })
            .then((channelList) => {
                channelList.forEach((channel) => {
                    monitoredChannels[channel.channel] = channel
                    this.populatePartyChannelMonitor(channel);
                });
            })
            .catch((err) => {
                console.error('Unable to initialize party finder database', err);
                throw err;
            });
    }

    populatePartyChannelMonitor(channel) {
        for (var partyChannelId of channel.partyChannel) {
            if (this.monitoredPartyChannels[partyChannelId] == undefined)
                this.monitoredPartyChannels[partyChannelId] = [];
            if (this.monitoredPartyChannels.indexOf(channel.channel) < 0)
                this.monitoredPartyChannels.push(channel.channel);
        }
    }
{'fraction_non_alphanumeric': 0.12414612414612415, 'fraction_numerical': 0.006237006237006237, 'mean_word_length': 1.7950207468879669, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, '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': '4915796', 'n_tokens_mistral': 1089, 'n_tokens_neox': 997, 'n_words': 188}