<commit_before>var Event = require('./events.model.js');
var commentController = require('../comments/comments.controller.js');
var Bluebird = require('bluebird');
var request = Bluebird.promisify(require('request'));
var utils = require('./utils.js');
var crontab = require('node-crontab');

/********************* Module.exports *************************/

module.exports = {
  addOne: addOne,
  fetchBatchDataFromKimonoAPI: fetchBatchDataFromKimonoAPI,
  fetchBatchDataFromEventbriteAPI: fetchBatchDataFromEventbriteAPI,
  addManySpoofs: addManySpoofs
};

/****************** scheduled function calls *****************/

//these scrapers run 6x a day, at 12:01, 4:01, 8:01, etc
var cronJob = crontab.scheduleJob("1 */4 * * *", function () {
  console.log("****************it's cron time!******************");
  fetchBatchDataFromEventbriteAPI();
  //fetchBatchDataFromKimonoAPI();
});



/******************** Generic DB interactions **********************/

function addOne(req, res) {
  // TODO: if (!req.body.coords) -> Make util call for address string from coords.lat,coords.lng;
  // TODO: add result of above operation to req.body/query for addEventRecord call
  console.log("Sending New Post to Database: ",req.body);
  utils.addEventRecord(req.body, res);
}

function addManySpoofs(req,res){
  res.status(200).end();
  var numSpoofs = req.query.number;
  for(var i = 0; i < numSpoofs; i++){
    var newEvent = new Event({
      title: 'Spoof event #' + i,
      startTime: Date.now(),
      endTime: Date.now()+20000000,
      lat: utils.generateRandomLat(),
      lng: utils.generateRandomLong(),
      user_id: 1,
      info: 'info for spoof event #' + i,
      category: 'Party',
      streetAddress1: '1 Embarcadero Blvd',
      streetAddress2: 'Suite 101',<commit_msg>reduce eventbrite fetching to 1x per day<commit_after>var Event = require('./events.model.js');
var commentController = require('../comments/comments.controller.js');
var Bluebird = require('bluebird');
var request = Bluebird.promisify(require('request'));
var utils = require('./utils.js');
var crontab = require('node-crontab');

/********************* Module.exports *************************/

module.exports = {
  addOne: addOne,
  fetchBatchDataFromKimonoAPI: fetchBatchDataFromKimonoAPI,
  fetchBatchDataFromEventbriteAPI: fetchBatchDataFromEventbriteAPI,
  addManySpoofs: addManySpoofs
};

/****************** scheduled function calls *****************/

// fetch new data at 12:03 am each day
var cronJob = crontab.scheduleJob("3 0 * * *", function () {
  console.log("****************it's cron time!******************");
  fetchBatchDataFromEventbriteAPI();
  //fetchBatchDataFromKimonoAPI();
});



/******************** Generic DB interactions **********************/

function addOne(req, res) {
  // TODO: if (!req.body.coords) -> Make util call for address string from coords.lat,coords.lng;
  // TODO: add result of above operation to req.body/query for addEventRecord call
  console.log("Sending New Post to Database: ",req.body);
  utils.addEventRecord(req.body, res);
}

function addManySpoofs(req,res){
  res.status(200).end();
  var numSpoofs = req.query.number;
  for(var i = 0; i < numSpoofs; i++){
    var newEvent = new Event({
      title: 'Spoof event #' + i,
      startTime: Date.now(),
      endTime: Date.now()+20000000,
      lat: utils.generateRandomLat(),
      lng: utils.generateRandomLong(),
      user_id: 1,
      info: 'info for spoof event #' + i,
      category: 'Party',
      streetAddress1: '1 Embarcadero Blvd',
      streetAddress2: 'Suite 101',
{'fraction_non_alphanumeric': 0.21414593234554097, 'fraction_numerical': 0.016214705060106235, 'mean_word_length': 4.538699690402477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2963232', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1104, 'n_words': 268}