<commit_before>request = require 'request'
_       = require 'lodash'

class TemperatureController
  celsius: (req, res) =>
    {city, state, country} = req.query
    location = _.compact([city, state, country]).join ','
    @request 'metric', location, (error, response, body) =>
      return res.status(500).send(error) if error?

      res.status(body.cod)
      return res.send(body.message) unless body.cod == 200
      res.send "#{body.main.temp}"

  fahrenheit: (req, res) =>
    {city, state, country} = req.query
    location = _.compact([city, state, country]).join ','
    @request 'imperial', location, (error, response, body) =>
      return res.status(500).send(error) if error?

      res.status(body.cod)
      return res.send(body.message) unless body.cod == 200
      res.send "#{body.main.temp}"

  request: (units, location, callback=->) =>
    options =
      url: 'http://api.openweathermap.org/data/2.5/weather'
      json: true
      qs:
        units: units
        q: location

    request options, callback

module.exports = TemperatureController<commit_msg>Return JSON object instead of a primitive<commit_after>request = require 'request'
_       = require 'lodash'

class TemperatureController
  celsius: (req, res) =>
    {city, state, country} = req.query
    location = _.compact([city, state, country]).join ','
    @request 'metric', location, (error, response, body) =>
      return res.status(500).send(error) if error?

      res.status(body.cod)
      return res.send(body.message) unless body.cod == 200
      res.send temperature: body.main.temp

  fahrenheit: (req, res) =>
    {city, state, country} = req.query
    location = _.compact([city, state, country]).join ','
    @request 'imperial', location, (error, response, body) =>
      return res.status(500).send(error) if error?

      res.status(body.cod)
      return res.send(body.message) unless body.cod == 200
      res.send temperature: body.main.temp

  request: (units, location, callback=->) =>
    options =
      url: 'http://api.openweathermap.org/data/2.5/weather'
      json: true
      qs:
        units: units
        q: location

    request options, callback

module.exports = TemperatureController
{'fraction_non_alphanumeric': 0.14182475158084915, 'fraction_numerical': 0.012646793134598013, 'mean_word_length': 3.034608378870674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4542368', 'n_tokens_mistral': 719, 'n_tokens_neox': 664, 'n_words': 175}