<commit_before>var debug = new (require('sdebug'))('server')
var underscore = require('underscore')
var wreck = require('wreck')

var DB = require('./database')
var Queue = require('./queue')
var Wallet = require('./wallet')

var profile = process.env.NODE_ENV || 'development'
var config = require('../config/config.' + profile + '.js')

underscore.keys(config).forEach((key) => {
  var m = config[key]
  if (typeof m === 'undefined') return

  underscore.keys(m).forEach((k) => {
    if (typeof m[k] === 'undefined') throw new Error('config.' + key + '.' + k + ': undefined')

    if ((typeof m[k] !== 'number') && (typeof m[k] !== 'boolean') && (!m[k])) {
      throw new Error('config.' + key + '.' + k + ': empty')
    }
  })
})

var runtime = {
  config: config,
  db: new DB(config),
  login: config.login,
  queue: new Queue(config)
}
runtime.wallet = new Wallet(config, runtime)

runtime.notify = (payload) => {
  var opts
  var params = runtime.config.slack

  debug('notify', payload)
  if (!(params && params.webhook && params.channel)) return debug('notify', 'slack webhook not configured')

  opts = { payload: underscore.extends({ channel: params.channel,
                                         username: params.username || 'webhookbot',
                                         icon_emoji: params.icon_emoji || ':ghost:',
                                         text: 'ping.' }, payload) }

  wreck.post(params.webhook, opts, (err, response, body) => {
    debug('notify', { payload: opts.payload, reason: err.toString() })
  })
}

module.exports = runtime<commit_msg>final notify debug<commit_after>var debug = new (require('sdebug'))('server')
var underscore = require('underscore')
var wreck = require('wreck')

var DB = require('./database')
var Queue = require('./queue')
var Wallet = require('./wallet')

var profile = process.env.NODE_ENV || 'development'
var config = require('../config/config.' + profile + '.js')

underscore.keys(config).forEach((key) => {
  var m = config[key]
  if (typeof m === 'undefined') return

  underscore.keys(m).forEach((k) => {
    if (typeof m[k] === 'undefined') throw new Error('config.' + key + '.' + k + ': undefined')

    if ((typeof m[k] !== 'number') && (typeof m[k] !== 'boolean') && (!m[k])) {
      throw new Error('config.' + key + '.' + k + ': empty')
    }
  })
})

var runtime = {
  config: config,
  db: new DB(config),
  login: config.login,
  queue: new Queue(config)
}
runtime.wallet = new Wallet(config, runtime)

runtime.notify = (payload) => {
  var opts
  var params = runtime.config.slack

  debug('notify', payload)
  if (!(params && params.webhook && params.channel)) return debug('notify', 'slack webhook not configured')

  opts = { payload: underscore.extends({ channel: params.channel,
                                         username: params.username || 'webhookbot',
                                         icon_emoji: params.icon_emoji || ':ghost:',
                                         text: 'ping.' }, payload) }

  wreck.post(params.webhook, opts, (err, response, body) => {
    if (err) return debug('notify', { payload: opts.payload, reason: err.toString() })

     debug('notify', opts.payload)
  })
}

module.exports = runtime
{'fraction_non_alphanumeric': 0.18074899411946765, 'fraction_numerical': 0.0, 'mean_word_length': 2.8892900120336944, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2431898', 'n_tokens_mistral': 975, 'n_tokens_neox': 957, 'n_words': 252}