<commit_before>var config = require('../config'),
  moment = require('moment-timezone'),
  request = require('request')

function Prices() {
  this.request = request
  return this;
}

Prices.prototype.at = function(dateTime, opts, callback) {
  var atTime = moment(dateTime)
  opts.url = config.priceUrlHourly
  opts.endDate = atTime.tz(config.timezone)
  this.getValues(opts, function(error, results) {
    if (error) {
      callback(error)
      return
    }
    for (let i=0; i<results.length; i++) {
      let date = results[i].date
      if (date.get('dayOfYear') == atTime.get('dayOfYear') &&
          date.get('hour') == atTime.get('hour')) {
        callback(null, results[i])
        return
      }
    }
    callback(new Error('No results found for ' + moment.format()))
  })
}

Prices.prototype.hourly = function(opts, callback) {
  opts.url = config.priceUrlHourly
  this.getValues(opts, callback)
}

Prices.prototype.daily = function(opts, callback) {
  opts.url = config.priceUrlDaily
  this.getValues(opts, callback)
}

Prices.prototype.weekly = function(opts, callback) {
  opts.url = config.priceUrlWeekly
  this.getValues(opts, callback)
}

Prices.prototype.monthly = function(opts, callback) {
  opts.url = config.priceUrlMonthly
  this.getValues(opts, callback)
}

Prices.prototype.yearly = function(opts, callback) {
  opts.url = config.priceUrlYearly
  this.getValues(opts, callback)
}

Prices.prototype.getValues = function(opts, callback) {
  if (!opts) {
    opts = {}
  }
  opts.currency = opts.currency || 'EUR'
  opts.area = opts.area || null
  // this weird format is used in e.g.
  // http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/
  // console.log(opts.url)
  var startDate, endDate;
  var url = opts.url +
    '?currency=,' + opts.currency + ',' + opts.currency + ',' + opts.currency
  if (opts.startDate) {
    startDate = moment(opts.startDate).hour(0).minute(0).second(0)
    url += '&startDate=' + startDate.format("DD-MM-YYYY")
  }
  if (opts.endDate) {
    endDate = moment(opts.endDate).hour(23).minute(59).second(59).millisecond(999)
    url += '&endDate=' + endDate.format("DD-MM-YYYY")
  }
  console.log(url);<commit_msg>cleaned comments<commit_after>var config = require('../config'),
  moment = require('moment-timezone'),
  request = require('request')

function Prices() {
  this.request = request
  return this;
}

Prices.prototype.at = function(dateTime, opts, callback) {
  var atTime = moment(dateTime)
  opts.url = config.priceUrlHourly
  opts.endDate = atTime.tz(config.timezone)
  this.getValues(opts, function(error, results) {
    if (error) {
      callback(error)
      return
    }
    for (let i=0; i<results.length; i++) {
      let date = results[i].date
      if (date.get('dayOfYear') == atTime.get('dayOfYear') &&
          date.get('hour') == atTime.get('hour')) {
        callback(null, results[i])
        return
      }
    }
    callback(new Error('No results found for ' + moment.format()))
  })
}

Prices.prototype.hourly = function(opts, callback) {
  opts.url = config.priceUrlHourly
  this.getValues(opts, callback)
}

Prices.prototype.daily = function(opts, callback) {
  opts.url = config.priceUrlDaily
  this.getValues(opts, callback)
}

Prices.prototype.weekly = function(opts, callback) {
  opts.url = config.priceUrlWeekly
  this.getValues(opts, callback)
}

Prices.prototype.monthly = function(opts, callback) {
  opts.url = config.priceUrlMonthly
  this.getValues(opts, callback)
}

Prices.prototype.yearly = function(opts, callback) {
  opts.url = config.priceUrlYearly
  this.getValues(opts, callback)
}

Prices.prototype.getValues = function(opts, callback) {
  if (!opts) {
    opts = {}
  }
  opts.currency = opts.currency || 'EUR'
  opts.area = opts.area || null
  var startDate, endDate;
  var url = opts.url +
    '?currency=,' + opts.currency + ',' + opts.currency + ',' + opts.currency
  if (opts.startDate) {
    startDate = moment(opts.startDate).hour(0).minute(0).second(0)
    url += '&startDate=' + startDate.format("DD-MM-YYYY")
  }
  if (opts.endDate) {
    endDate = moment(opts.endDate).hour(23).minute(59).second(59).millisecond(999)
    url += '&endDate=' + endDate.format("DD-MM-YYYY")
  }
{'fraction_non_alphanumeric': 0.15846994535519127, 'fraction_numerical': 0.006414825374198147, 'mean_word_length': 3.596069868995633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '1944574', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1443, 'n_words': 258}