<commit_before>/* global emit */

// IMPORTANT:
// when this is ran directly, set up the DB
// otherwise just be a library that handles all storage

// XXX
// this could use some DRY love

var cradle = require("cradle")
,   async = require("async")
,   log
;

// helpers
function couchNow (d) {
    if (!d) d = new Date();
    return [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(), d.getUTCHours(),
            d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()];
}

function Store (config) {
    var dbName = config.couchDB || "ash-nazg"
    ,   couchConf = {}
    ;
    log = require("./log")(config);
    if (config.couchAuth) couchConf.auth = config.couchAuth;
    this.client = new cradle.Connection(couchConf);
    this.db = this.client.database(dbName);
    this._config = config;
    log.info("Connected to CouchDB, db=" + dbName);<commit_msg>Allow custom port for couchDb connection<commit_after>/* global emit */

// IMPORTANT:
// when this is ran directly, set up the DB
// otherwise just be a library that handles all storage

// XXX
// this could use some DRY love

var cradle = require("cradle")
,   async = require("async")
,   log
;

// helpers
function couchNow (d) {
    if (!d) d = new Date();
    return [d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(), d.getUTCHours(),
            d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()];
}

function Store (config) {
    var dbName = config.couchDB || "ash-nazg"
    ,   couchConf = {}
    ;
    log = require("./log")(config);
    if (config.couchAuth) couchConf.auth = config.couchAuth;
    if (config.couchDbPort) couchConf.port = config.couchDbPort;
    this.client = new cradle.Connection(couchConf);
    this.db = this.client.database(dbName);
    this._config = config;
    log.info("Connected to CouchDB, db=" + dbName);
{'fraction_non_alphanumeric': 0.14885496183206107, 'fraction_numerical': 0.0010905125408942203, 'mean_word_length': 3.208715596330275, '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': '6824751', 'n_tokens_mistral': 624, 'n_tokens_neox': 629, 'n_words': 166}