<commit_before>import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { _ } from 'meteor/underscore';
import debug from '../debug';
import { RedisPipe, Events } from '../constants';
import getFieldsOfInterestFromAll from './lib/getFieldsOfInterestFromAll';
import Config from '../config';

class RedisSubscriptionManager {
    init() {
        if (this.isInitialized) {
            return;
        }
        this.uid = Random.id();
        this.queue = new Meteor._SynchronousQueue();
        this.store = {}; // {channel: [RedisSubscribers]}
        this.channelHandlers = {}; // {channel: handler}

        this.isInitialized = true;
    }

    /**
     * Returns all RedisSubscribers regardless of channel
     */
    getAllRedisSubscribers() {
        let redisSubscribers = [];
        for (channel in this.store) {
            this.store[channel].forEach(_redisSubscriber =>
                redisSubscribers.push(_redisSubscriber)
            );
        }

        return redisSubscribers;
    }

    /**
     * @param redisSubscriber
     */
    attach(redisSubscriber) {
        this.queue.queueTask(() => {
            _.each(redisSubscriber.channels, channel => {
                if (!this.store[channel]) {
                    this.initializeChannel(channel);
                }

                this.store[channel].push(redisSubscriber);
            });
        });
    }

    /**
     * @param redisSubscriber
     */
    detach(redisSubscriber) {
        this.queue.runTask(() => {<commit_msg>Forgot to add queueTask in RSM<commit_after>import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { _ } from 'meteor/underscore';
import debug from '../debug';
import { RedisPipe, Events } from '../constants';
import getFieldsOfInterestFromAll from './lib/getFieldsOfInterestFromAll';
import Config from '../config';

class RedisSubscriptionManager {
    init() {
        if (this.isInitialized) {
            return;
        }
        this.uid = Random.id();
        this.queue = new Meteor._SynchronousQueue();
        this.store = {}; // {channel: [RedisSubscribers]}
        this.channelHandlers = {}; // {channel: handler}

        this.isInitialized = true;
    }

    /**
     * Returns all RedisSubscribers regardless of channel
     */
    getAllRedisSubscribers() {
        let redisSubscribers = [];
        for (channel in this.store) {
            this.store[channel].forEach(_redisSubscriber =>
                redisSubscribers.push(_redisSubscriber)
            );
        }

        return redisSubscribers;
    }

    /**
     * @param redisSubscriber
     */
    attach(redisSubscriber) {
        this.queue.queueTask(() => {
            _.each(redisSubscriber.channels, channel => {
                if (!this.store[channel]) {
                    this.initializeChannel(channel);
                }

                this.store[channel].push(redisSubscriber);
            });
        });
    }

    /**
     * @param redisSubscriber
     */
    detach(redisSubscriber) {
        this.queue.queueTask(() => {
{'fraction_non_alphanumeric': 0.12730210016155089, 'fraction_numerical': 0.0, 'mean_word_length': 2.017543859649123, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7375323', 'n_tokens_mistral': 904, 'n_tokens_neox': 870, 'n_words': 161}