<commit_before>var _ = require('lodash');
var fs = require('fs');
var path = require('path');

var objs = {};
var models = {};
var db = {
  connection: {
    readyState: 1
  },
  model: function(name, obj) {
    if (obj !== undefined) {
      models[name] = obj
    }
    return models[name];
  }
};

function Post(obj) {
  this.id = obj.id;
  this.email = obj.email;
  this.path = obj.path;
  this.created = obj.created || new Date;
}

Post.save = Post.prototype.save = function(callback) {
  objs[this.id] = this;
  if (callback) {
    callback();
  }
};

Post.find = Post.prototype.find = function(search, callback) {
  var items = []
  if (_.isEmpty(search)) {
    _.forEach(objs, function(obj) {
      items.push(obj)}
    );
    callback(undefined, items);
    return;
  }
  _.forEach(objs, function(obj) {
    _.forEach(search, function(val, key) {
      if (obj[key] === val) {
        items.push(obj);
      }
    });
  });
  callback(undefined, items);
};

db.model('Post', Post);

fs.readdir('image', function(err, files) {
  if (err) {
    console.log(err);
    return;
  }
  files.forEach(function(file) {
    var m = /^(.*)\.jpg$/.exec(file);
    if (m) {
      var stat = fs.statSync(path.join('image', file));
      new Post({id: m[1], created: stat.mtime}).save();
    }
  });
});

module.exports = db;
<commit_msg>Keep quiet on test<commit_after>var _ = require('lodash');
var fs = require('fs');
var path = require('path');

var objs = {};
var models = {};
var db = {
  connection: {
    readyState: 1
  },
  model: function(name, obj) {
    if (obj !== undefined) {
      models[name] = obj
    }
    return models[name];
  }
};

function Post(obj) {
  this.id = obj.id;
  this.email = obj.email;
  this.path = obj.path;
  this.created = obj.created || new Date;
}

Post.save = Post.prototype.save = function(callback) {
  objs[this.id] = this;
  if (callback) {
    callback();
  }
};

Post.find = Post.prototype.find = function(search, callback) {
  var items = []
  if (_.isEmpty(search)) {
    _.forEach(objs, function(obj) {
      items.push(obj)}
    );
    callback(undefined, items);
    return;
  }
  _.forEach(objs, function(obj) {
    _.forEach(search, function(val, key) {
      if (obj[key] === val) {
        items.push(obj);
      }
    });
  });
  callback(undefined, items);
};

db.model('Post', Post);

fs.readdir('image', function(err, files) {
  if (err) {
    // image directory does not exist
    return;
  }
  files.forEach(function(file) {
    var m = /^(.*)\.jpg$/.exec(file);
    if (m) {
      var stat = fs.statSync(path.join('image', file));
      new Post({id: m[1], created: stat.mtime}).save();
    }
  });
});

module.exports = db;

{'fraction_non_alphanumeric': 0.1914338919925512, 'fraction_numerical': 0.0014897579143389199, 'mean_word_length': 2.761904761904762, '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': '2662830', 'n_tokens_mistral': 976, 'n_tokens_neox': 967, 'n_words': 203}