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


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

//these scrapers run 5x 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();
});


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

module.exports = {
  getAll: getAll,
  getOne: getOne,
  addOne: addOne,
  getLocal: getLocal,
  fetchBatchDataFromKimonoAPI: fetchBatchDataFromKimonoAPI,
  fetchBatchDataFromEventbriteAPI: fetchBatchDataFromEventbriteAPI,
  getCoordsFromAddress: getCoordsFromAddress,
  getAddressFromCoords: getAddressFromCoords
};

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

function getAll(req, res) {
  Event.fetchAll({
      withRelated: ['user','rating']
  }).then(function (collection) {
    utils.sendResponse(utils.trim(collection),res);
  });
}

function getOne(req, res) {
  Event.where({id:req.params.id}).fetch({
      withRelated: ['user','rating']
    }).then(function (record) {<commit_msg>make events API calls return sum of ratings, not list of ratings objects<commit_after>
var Event = require('./events.model.js');
var Promise = require('bluebird');
var request = Promise.promisify(require('request'));
var utils = require('./utils.js');
var crontab = require('node-crontab');


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

//these scrapers run 5x 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();
});



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

module.exports = {
  getAll: getAll,
  getOne: getOne,
  addOne: addOne,
  getLocal: getLocal,
  fetchBatchDataFromKimonoAPI: fetchBatchDataFromKimonoAPI,
  fetchBatchDataFromEventbriteAPI: fetchBatchDataFromEventbriteAPI,
  getCoordsFromAddress: getCoordsFromAddress,
  getAddressFromCoords: getAddressFromCoords
};

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

function getAll(req, res) {
  Event.fetchAll({
      withRelated: ['user','rating']
  }).then(function (collection) {
    utils.sendResponse(utils.trim(collection),res);
  });
}

function getOne(req, res) {
  Event.where({id:req.params.id}).fetch({
      withRelated: ['user','rating']
    }).then(function (record) {
{'fraction_non_alphanumeric': 0.24358974358974358, 'fraction_numerical': 0.009523809523809525, 'mean_word_length': 5.793532338308458, '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': '2873905', 'n_tokens_mistral': 851, 'n_tokens_neox': 817, 'n_words': 168}