<commit_before>'use strict';

var _ = require('lodash');
var chance = require('./fake-extension'); // TODO: Can I just import chance and have this wired up differently
var moment = require('moment'); 
var request = require('superagent');
var requestMock = require('superagent-mocker')(request);
var glimpse = require('glimpse');
var polyfill = require('event-source');

// TODO: remove into its own module
var streamMock = (function() {
    var mocks = {};
    
    return {
        on: function(url, mockCallback) {
            mocks[url] = mockCallback;
        },
        trigger: function(url, userCallback) {
            if (mocks[url]) {
                var result = mocks[url](); 
                userCallback(result);
            }
        }
    }
})();

polyfill.EventSource = function(url) {
    this.url = url; 
    
    streamMock.trigger(url, function() {});
};

    
var _rawRequestCache = {};
 
var requestProcessor = {
    requests: {  
        summary: function(rawRequests) {
            var requests = _.map(rawRequests, 'request');
            var messages = _.union.apply(undefined, _.map(rawRequests, 'messages'));
            var newMessageTypes = {};
            
            // TODO: Would prefer not to have duplicate work work here (as request-repository-message)
            // process message types
            _.forEach(messages, function(message) {
                _.forEach(message.types, function(type) {
                    if (!newMessageTypes[type]) {
                        newMessageTypes[type] = [];<commit_msg>Fixup mock surface area now that we have updated event source usage<commit_after>'use strict';

var _ = require('lodash');
var chance = require('./fake-extension'); // TODO: Can I just import chance and have this wired up differently
var moment = require('moment'); 
var request = require('superagent');
var requestMock = require('superagent-mocker')(request);
var glimpse = require('glimpse');
var polyfill = require('event-source');

// TODO: remove into its own module
var streamMock = (function() {
    var mocks = {};
    
    return {
        on: function(url, mockCallback) {
            mocks[url] = mockCallback;
        },
        trigger: function(url, userCallback) {
            if (mocks[url]) {
                var result = mocks[url](); 
                userCallback(result);
            }
        }
    };
})();

polyfill.EventSource = function(url) {
    this.url = url; 
    
    streamMock.trigger(url, function() {});
};
polyfill.EventSource.prototype = {
    addEventListener: function(topic, callback) {
    }  
};

    
var _rawRequestCache = {};
 
var requestProcessor = {
    requests: {  
        summary: function(rawRequests) {
            var requests = _.map(rawRequests, 'request');
            var messages = _.union.apply(undefined, _.map(rawRequests, 'messages'));
            var newMessageTypes = {};
            
            // TODO: Would prefer not to have duplicate work work here (as request-repository-message)
            // process message types
            _.forEach(messages, function(message) {
                _.forEach(message.types, function(type) {
                    if (!newMessageTypes[type]) {
                        newMessageTypes[type] = [];
{'fraction_non_alphanumeric': 0.1263449123885644, 'fraction_numerical': 0.0, 'mean_word_length': 2.2769385699899294, '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': '7363371', 'n_tokens_mistral': 863, 'n_tokens_neox': 849, 'n_words': 227}