<commit_before>/**
 * Created by <NAME>
 * @type {*|exports|module.exports}
 */
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Consts = require('./../settings.json');
var sha1 = require('sha1');

mongoose.connect(Consts.MONGOLAB_DB);

var personSchema = new Schema({
  name: String,
  alias: String,
  uid: String
}, { collection: 'skype_person' });

var messageSchema = new Schema({
  _composer: { type: Schema.Types.ObjectId, ref: 'Person' },
  _thread: { type: Schema.Types.ObjectId, ref: 'Thread' },
  content: String,
  composedAt: Date
}, { collection: 'skype_message' });

var threadSchema = new Schema({
  name: String,
  uid: String
}, { collection: 'skype_thread' });

var Message = mongoose.model('Message', messageSchema);
var Thread = mongoose.model('Thread', threadSchema);
var Person = mongoose.model('Person', personSchema);

exports.saveMessage = function (msg, callback) {
  getOrCreateThread(msg, function (error, thread) {
    if (error) {
      return callback(error);
    }
    getOrCreatePerson(msg, function (_error, person) {
      if (_error) {
        return callback(_error);
      }
      var message = new Message({
        content: msg.resource.content,
        composedAt: msg.resource.composetime,
        _thread: thread._id,
        _composer: person._id
      });
      console.log(message);
      return message.save(function (__error) {
        if (__error) {
          return callback(__error);
        }<commit_msg>added<commit_after>/**
 * Created by <NAME>
 * @type {*|exports|module.exports}
 */
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Consts = require('./../settings.json');
var sha1 = require('sha1');

mongoose.connect(Consts.MONGOLAB_DB);

var personSchema = new Schema({
  name: String,
  alias: String,
  uid: String
}, { collection: 'skype_person' });

var messageSchema = new Schema({
  _composer: { type: Schema.Types.ObjectId, ref: 'Person' },
  _thread: { type: Schema.Types.ObjectId, ref: 'Thread' },
  content: String,
  composedAt: Date
}, { collection: 'skype_message' });

var threadSchema = new Schema({
  name: String,
  uid: String
}, { collection: 'skype_thread' });

var Message = mongoose.model('Message', messageSchema);
var Thread = mongoose.model('Thread', threadSchema);
var Person = mongoose.model('Person', personSchema);

exports.saveMessage = function (msg, callback) {
  getOrCreateThread(msg, function (error, thread) {
    if (error) {
      return callback(error);
    }
    getOrCreatePerson(msg, function (_error, person) {
      if (_error) {
        return callback(_error);
      }
      var message = new Message({
        content: msg.resource.content,
        composedAt: msg.resource.composetime,
        _thread: thread._id,
        _composer: person._id
      });
      return message.save(function (__error) {
        if (__error) {
          return callback(__error);
        }
{'fraction_non_alphanumeric': 0.14315068493150684, 'fraction_numerical': 0.0013698630136986301, 'mean_word_length': 3.500770416024653, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2424676', 'n_tokens_mistral': 887, 'n_tokens_neox': 903, 'n_words': 225}