<commit_before>var config = require('config');
var convert = require('convert');
var debug = require('debug')(config.application() + ':route');
var model = require('model');
var defaults = require('model-defaults');
var session = require('session');

/**
 * MPS to MPH
 */

var MPS_TO_MPH = 2.23694;

/**
 * Expose `Route`
 */

var Route = module.exports = model('Route')
  .use(defaults({
    costPenalty: false,
    costSavings: false,
    timeSavings: false,
    transit: [],
    weightLost: false
  }))
  .attr('id')
  .attr('access')
  .attr('bikeCalories')
  .attr('bikeDistance')
  .attr('bikeTime')
  .attr('calories')
  .attr('cost')
  .attr('costPenalty')
  .attr('costSavings')
  .attr('driveDistance')
  .attr('egress')
  .attr('emissions')
  .attr('emissionsDifference')
  .attr('hasTransit')
  .attr('modes')
  .attr('score')
  .attr('stats')
  .attr('time')
  .attr('timeSavings')
  .attr('transfers')
  .attr('transitCost')
  .attr('transit')
  .attr('trips')
  .attr('walkCalories')
  .attr('walkDistance')
  .attr('walkTime')
  .attr('weightLost');

/**
 * Update scoring
 */

Route.prototype.rescore = function(scorer) {
  var data = scorer.processOption(this.toJSON());

  for (var i in data) {
    if (this.hasOwnProperty(i) && i !== 'transitCost') {
      this[i](data[i]);
    }
  }

  this.emit('change average', this.average());
  this.emit('change bikeTime', this.bikeTime());
  this.emit('change calculatedCost', this.calculatedCost());
  this.emit('change calculatedCalories', this.calculatedCalories());
  this.emit('change transitCosts', this.transitCosts());
  this.emit('change tripsPerYear', this.tripsPerYear());
  this.emit('change carParkingCost', this.carParkingCost());
  this.emit('change vmtRate', this.vmtRate());
  this.emit('change walkTime', this.walkTime());
};

/**
 * Set car data
 */

Route.prototype.setCarData = function(data) {
  var m = this.tripm();

  var costDifference = data.cost * m - this.cost() * m;
  var emissions = (data.emissions - this.emissions()) / 2000;
  var weightLost = this.calories() === 0
    ? false
    : convert.caloriesToPounds(this.calories()) * m | 0;
  var timeSavings = (this.timeInTransit() - (data.time - this.time())) * m;

  console.log(data.time, this.time(), this.timeInTransit());

  if (this.directCar()) {
    costDifference = data.cost * m / 2;
    emissions /= 2;
    timeSavings /= 2; // Assume split driving
  }

  if (costDifference > 0) this.costSavings(costDifference);
  if (weightLost) this.weightLost(weightLost);
  if (timeSavings > 0) this.timeSavings(timeSavings / 60 / 24 | 0);
  if (emissions > 0) this.emissionsDifference(emissions | 0);
};
<commit_msg>Remove console.log, add default modes array<commit_after>var config = require('config');
var convert = require('convert');
var debug = require('debug')(config.application() + ':route');
var model = require('model');
var defaults = require('model-defaults');
var session = require('session');

/**
 * MPS to MPH
 */

var MPS_TO_MPH = 2.23694;

/**
 * Expose `Route`
 */

var Route = module.exports = model('Route')
  .use(defaults({
    costPenalty: false,
    costSavings: false,
    modes: [],
    timeSavings: false,
    transit: [],
    weightLost: false
  }))
  .attr('id')
  .attr('access')
  .attr('bikeCalories')
  .attr('bikeDistance')
  .attr('bikeTime')
  .attr('calories')
  .attr('cost')
  .attr('costPenalty')
  .attr('costSavings')
  .attr('driveDistance')
  .attr('egress')
  .attr('emissions')
  .attr('emissionsDifference')
  .attr('hasTransit')
  .attr('modes')
  .attr('score')
  .attr('stats')
  .attr('time')
  .attr('timeSavings')
  .attr('transfers')
  .attr('transitCost')
  .attr('transit')
  .attr('trips')
  .attr('walkCalories')
  .attr('walkDistance')
  .attr('walkTime')
  .attr('weightLost');

/**
 * Update scoring
 */

Route.prototype.rescore = function(scorer) {
  var data = scorer.processOption(this.toJSON());

  for (var i in data) {
    if (this.hasOwnProperty(i) && i !== 'transitCost') {
      this[i](data[i]);
    }
  }

  this.emit('change average', this.average());
  this.emit('change bikeTime', this.bikeTime());
  this.emit('change calculatedCost', this.calculatedCost());
  this.emit('change calculatedCalories', this.calculatedCalories());
  this.emit('change transitCosts', this.transitCosts());
  this.emit('change tripsPerYear', this.tripsPerYear());
  this.emit('change carParkingCost', this.carParkingCost());
  this.emit('change vmtRate', this.vmtRate());
  this.emit('change walkTime', this.walkTime());
};

/**
 * Set car data
 */

Route.prototype.setCarData = function(data) {
  var m = this.tripm();

  var costDifference = data.cost * m - this.cost() * m;
  var emissions = (data.emissions - this.emissions()) / 2000;
  var weightLost = this.calories() === 0
    ? false
    : convert.caloriesToPounds(this.calories()) * m | 0;
  var timeSavings = (this.timeInTransit() - (data.time - this.time())) * m;

  if (this.directCar()) {
    costDifference = data.cost * m / 2;
    emissions /= 2;
    timeSavings /= 2; // Assume split driving
  }

  if (costDifference > 0) this.costSavings(costDifference);
  if (weightLost) this.weightLost(weightLost);
  if (timeSavings > 0) this.timeSavings(timeSavings / 60 / 24 | 0);
  if (emissions > 0) this.emissionsDifference(emissions | 0);
};

{'fraction_non_alphanumeric': 0.1872524985857062, 'fraction_numerical': 0.00905148029417311, 'mean_word_length': 3.9896519285042333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1836983', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1830, 'n_words': 363}