<commit_before>process.env.MONGODB_URI = 'mongodb://localhost:27017/shopper-test';
require('../lib/connection');
const mongoose = require('mongoose');

before(() => mongoose.connection.dropDatabase());<commit_msg>added scripts for autoloading data to the db<commit_after>process.env.MONGODB_URI = 'mongodb://localhost:27017/shopper-test';
require('../lib/connection');
const childProcess = require('child_process');
const mongoose = require('mongoose');


function loadData(collection) {
    return `mongoimport --db shopper-test --collection ${collection} --file data/${collection}.json --jsonArray`;
}

before(done => {
    mongoose.connection.dropDatabase();
    childProcess.exec(loadData('users'), err => {
        if(err) return done(err);
        childProcess.exec(loadData('accounts'), err => {
            if(err) return done(err);
            childProcess.exec(loadData('stores'), err => {
                if(err) return done(err);
                childProcess.exec(loadData('items'), err => {
                    if(err) return done(err);
                    childProcess.exec(loadData('lists'), done);
                });
            });
        });
    });
});
{'fraction_non_alphanumeric': 0.16538789428815004, 'fraction_numerical': 0.008525149190110827, 'mean_word_length': 3.0622837370242215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '457315', 'n_tokens_mistral': 343, 'n_tokens_neox': 337, 'n_words': 58}