<commit_before>var _ = require('lodash');
var colors = require('colors');
var schema = require('js-schema');
var achievibitDB = require('./achievibitDB');
var utilities = require('./utilities');
var console = require('./consoleService')('GITHUB-EVENTS', [
  'blue',
  'inverse'
], process.console);
var nconf = require('nconf');

nconf.argv().env();

// require all the achievement files
var achievements = require('require-all')({
  dirname: __dirname + '/achievements',
  filter: /(.+achievement)\.js$/,
  excludeDirs: /^\.(git|svn)$/,
  recursive: true
});

// OUR SCHEMAS!
var Achievement = schema({
  avatar: String,
  name: String,
  short: String,
  description: String,
  relatedPullRequest: String
});

var Treasure = schema({
  name: String,
  gem: [String, Number, Boolean]
});

// all currently open pull requests
var pullRequests = {};

var EventManager = function() {
  var self = this;

  self.notifyAchievements = function(githubEvent, eventData, io) {
        /**
         * NEW REPO CONNECTED!!!
         * a repo added achievibit as a GitHub webhook!
         */
    if (_.isEqual(githubEvent, 'ping')) {
      var repo = utilities.parseRepo(eventData.repository);

      if (utilities.isPullRequestAssociatedWithOrganization(eventData)) {
        repo.organization =
          utilities.parseUser(eventData.repository.owner, true);
      }

      achievibitDB.insertItem('repos', repo);
    }

        /**
         * INIT PULL REQUEST DATA
         * Get the data as it was when the pull request opened.
         * This will allow us to notify the achievements if something changed
         * in case some achievements want to deal with changing things.
         * notice that labels are given as a different event with the same
         * time, so that way we know if that was an added label at creation
         * or later
         */
    if (_.isEqual(githubEvent, 'pull_request') &&
            //_.isEqual(eventData.action, 'reopened') ?<commit_msg>fix repo insert on ping event<commit_after>var _ = require('lodash');
var colors = require('colors');
var schema = require('js-schema');
var achievibitDB = require('./achievibitDB');
var utilities = require('./utilities');
var console = require('./consoleService')('GITHUB-EVENTS', [
  'blue',
  'inverse'
], process.console);
var nconf = require('nconf');

nconf.argv().env();

// require all the achievement files
var achievements = require('require-all')({
  dirname: __dirname + '/achievements',
  filter: /(.+achievement)\.js$/,
  excludeDirs: /^\.(git|svn)$/,
  recursive: true
});

// OUR SCHEMAS!
var Achievement = schema({
  avatar: String,
  name: String,
  short: String,
  description: String,
  relatedPullRequest: String
});

var Treasure = schema({
  name: String,
  gem: [String, Number, Boolean]
});

// all currently open pull requests
var pullRequests = {};

var EventManager = function() {
  var self = this;

  self.notifyAchievements = function(githubEvent, eventData, io) {
        /**
         * NEW REPO CONNECTED!!!
         * a repo added achievibit as a GitHub webhook!
         */
    if (_.isEqual(githubEvent, 'ping')) {
      var repo = utilities.parseRepo(eventData.repository);

      if (utilities.isPullRequestAssociatedWithOrganization(eventData)) {
        repo.organization =
          utilities.parseUser(eventData.repository.owner, true).username;
      }

      achievibitDB.insertItem('repos', repo);
    }

        /**
         * INIT PULL REQUEST DATA
         * Get the data as it was when the pull request opened.
         * This will allow us to notify the achievements if something changed
         * in case some achievements want to deal with changing things.
         * notice that labels are given as a different event with the same
         * time, so that way we know if that was an added label at creation
         * or later
         */
    if (_.isEqual(githubEvent, 'pull_request') &&
            //_.isEqual(eventData.action, 'reopened') ?
{'fraction_non_alphanumeric': 0.12610118298514977, 'fraction_numerical': 0.0, 'mean_word_length': 3.0100908173562058, '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': '1495360', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1143, 'n_words': 355}