<commit_before>'use strict';

var mongo = require('./mongo'),
    ObjectID = mongo.ObjectID;

/**
 * Populates the database with seed data.
 * @param overwrite Overwrite existing database even if it is not empty.
 */
module.exports = function *(overwrite) {
  var count = yield mongo.users.count({}, {limit: 1});
  if (overwrite || count === 0) {

    // first remove any leftover data in collections
    var collerrmsg = 'ns not found' /* indicates 'collection not found' error in mongo which is ok */;
    for (var collection in mongo) {
      if (mongo[collection].drop) {
        try {
          yield mongo[collection].drop();
        } catch (err) {
          if (err.message !== collerrmsg) {
            throw err;
          }
        }
      }
    }

    // now populate collections with fresh data
    yield mongo.counters.insert({_id: 'userId', seq: users.length});
    yield mongo.users.insert(users);
    yield mongo.posts.insert(posts);
  }
};

// declare seed data
var users = [
  {
    _id: 1,
    email: '<EMAIL>',
    password: '<PASSWORD>',
    name: '<NAME>',
    picture: <KEY>
  },
  {
    _id: 2,
    email: '<EMAIL>',
    password: '<PASSWORD>',
    name: '<NAME>',
    picture: <KEY>MDAwMDAwMD<KEY>
  }
];


Date.prototype.subtractHours = function (h) {
  return new Date(new Date(this).setHours(this.getHours() - h));
};
var now = new Date();
var posts = [
  {
    _id: new ObjectID(),
    from: {_id: 2, name: '<NAME>', picture: 'api/users/2/picture'},
    message: 'Hello world! This is a sample post... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat neque dui, vel fermentum arcu egestas vitae. Curabitur tincidunt tristique tristique. Nunc velit sapien, laoreet non enim vel, vestibulum blandit magna. Vivamus pharetra tempus mi, id ullamcorper dolor adipiscing at. Aliquam sed malesuada sapien. Sed enim nisi, rhoncus nec sollicitudin quis, mattis sed eros. Etiam luctus aliquam tristique. Aenean condimentum justo arcu, sit amet vestibulum neque suscipit sit amet. Nunc mattis enim eget turpis semper bibendum. Quisque blandit diam tincidunt lacus malesuada, vel faucibus risus hendrerit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque viverra tellus bibendum, elementum urna ultricies, elementum enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam nunc turpis, commodo id ipsum ac, rhoncus auctor ligula. Proin in nulla in lorem commodo semper. Aenean sodales turpis vitae tempor sollicitudin.',
    createdTime: now.subtractHours(28)
  },
  {
    _id: new ObjectID(),
    from: {_id: 1, name: '<NAME>', picture: 'api/users/1/picture'},
    message: 'Hi guys, I\'m traveling to Bolivia for the weekend!',
    createdTime: now.subtractHours(97),
    updatedTime: now.subtractHours(24),
    comments: [
      {
        _id: new ObjectID(),
        from: {_id: 2, name: '<NAME>', picture: 'api/users/2/picture'},
        createdTime: now.subtractHours(26),
        message: 'Don\'t forget to bring back an iguana:)'
      },
      {
        _id: new ObjectID(),
        from: {_id: 1, name: '<NAME>', picture: 'api/users/1/picture'},
        createdTime: now.subtractHours(24),
        message: 'I will!.'
      }
    ]
  }
];<commit_msg>subtle fixes<commit_after>'use strict';

var mongo = require('./mongo'),
    ObjectID = mongo.ObjectID;

/**
 * Populates the database with seed data.
 * @param overwrite Overwrite existing database even if it is not empty.
 */
module.exports = function *(overwrite) {
  var count = yield mongo.users.count({}, {limit: 1});
  if (overwrite || count === 0) {

    // first remove any leftover data in collections
    var collerrmsg = 'ns not found' /* indicates 'collection not found' error in mongo which is ok */;
    for (var collection in mongo) {
      if (mongo[collection].drop) {
        try {
          yield mongo[collection].drop();
        } catch (err) {
          if (err.message !== collerrmsg) {
            throw err;
          }
        }
      }
    }

    // now populate collections with fresh data
    yield mongo.counters.insert({_id: 'userId', seq: users.length});
    yield mongo.users.insert(users);
    yield mongo.posts.insert(posts);
  }
};

// declare seed data
var users = [
  {
    _id: 1,
    email: '<EMAIL>',
    password: '<PASSWORD>',
    name: '<NAME>',
    picture: <KEY>
  },
  {
    _id: 2,
    email: '<EMAIL>',
    password: '<PASSWORD>',
    name: '<NAME>',
    picture: <KEY>
  }
];


var now = new Date();
function getTime(h) {
  return new Date(new Date(now).setHours(now.getHours() + h));
}

var posts = [
  {
    _id: new ObjectID(),
    from: {_id: 1, name: '<NAME>', picture: 'api/users/1/picture'},
    message: 'Hi guys, I\'m traveling to Bolivia for the weekend!',
    createdTime: getTime(-97),
    updatedTime: getTime(-24),
    comments: [
      {
        _id: new ObjectID(),
        from: {_id: 2, name: '<NAME>', picture: 'api/users/2/picture'},
        createdTime: getTime(-26),
        message: 'Don\'t forget to bring back an iguana:)'
      },
      {
        _id: new ObjectID(),
        from: {_id: 1, name: '<NAME>', picture: 'api/users/1/picture'},
        createdTime: getTime(-24),
        message: 'I will!.'
      }
    ]
  },
  {
    _id: new ObjectID(),
    from: {_id: 2, name: '<NAME>', picture: 'api/users/2/picture'},
    message: 'Hello world! This is a sample post... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat neque dui, vel fermentum arcu egestas vitae. Curabitur tincidunt tristique tristique. Nunc velit sapien, laoreet non enim vel, vestibulum blandit magna. Vivamus pharetra tempus mi, id ullamcorper dolor adipiscing at. Aliquam sed malesuada sapien. Sed enim nisi, rhoncus nec sollicitudin quis, mattis sed eros. Etiam luctus aliquam tristique. Aenean condimentum justo arcu, sit amet vestibulum neque suscipit sit amet. Nunc mattis enim eget turpis semper bibendum. Quisque blandit diam tincidunt lacus malesuada, vel faucibus risus hendrerit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque viverra tellus bibendum, elementum urna ultricies, elementum enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam nunc turpis, commodo id ipsum ac, rhoncus auctor ligula. Proin in nulla in lorem commodo semper. Aenean sodales turpis vitae tempor sollicitudin.',
    createdTime: getTime(-28)
  }
];
{'fraction_non_alphanumeric': 0.12089437162683114, 'fraction_numerical': 0.006784888203546646, 'mean_word_length': 3.0588235294117645, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2321968', 'n_tokens_mistral': 2234, 'n_tokens_neox': 2186, 'n_words': 708}