<commit_before><commit_msg>has to happen: userdelete implemented<commit_after>#!/usr/bin/env nodejs
var _ = require('lodash');
var moment = require('moment');
var Promise = require('bluebird');
var mongodb = Promise.promisifyAll(require('mongodb'));
var debug = require('debug')('userdelete');
var nconf = require('nconf');

var mongo = require('./lib/mongo');

var cfgFile = "config/settings.json";

nconf.argv()
     .env()
     .file({ file: cfgFile });

console.log("Checking variable 'id'");
var userId = _.parseInt(nconf.get('id'));
debug("userId is %d", userId);

if(!userId)
    process.exit(1);


return Promise
    .all([
        mongo.countByMatch(nconf.get('schema').supporters, { userId: userId }),
        mongo.countByMatch(nconf.get('schema').htmls, { userId: userId }),
        mongo.countByMatch(nconf.get('schema').impressions, { userId: userId }),
        mongo.countByMatch(nconf.get('schema').timelines, { userId: userId })
    ])
    .tap(function(every) {
        debug("Respective amount %j, waiting before deleting, 5s...", every);
    })
    .delay(5000)
    .then(function() {
        return Promise.all([
            mongo.remove(nconf.get('schema').supporters, { userId: userId }),
            mongo.remove(nconf.get('schema').htmls, { userId: userId }),
            mongo.remove(nconf.get('schema').impressions, { userId: userId }),
            mongo.remove(nconf.get('schema').timelines, { userId: userId })
        ])
    })
    .then(function(done) {
        debug("Done!");
    });
{'fraction_non_alphanumeric': 0.18337730870712401, 'fraction_numerical': 0.00395778364116095, 'mean_word_length': 3.4486803519061584, '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': '6908099', 'n_tokens_mistral': 484, 'n_tokens_neox': 499, 'n_words': 88}