<commit_before>require 'uri'
require 'net/http'
require 'json'

module SendgridHelper
  # Get stats associated with an email from SendGrid
  #
  # Returns a hash of numbers like
  #
  #  {"delivered"=>0, "unsubscribes"=>0, "name"=>"email_1000",
  #  "invalid_email"=>0, "bounces"=>0, "repeat_unsubscribes"=>0,
  #  "unique_clicks"=>0, "spam_drop"=>0, "repeat_bounces"=>0,
  #  "repeat_spamreports"=>0, "blocked"=>0, "requests"=>0,
  #  "spamreports"=>0, "clicks"=>0, "opens"=>0, "unique_opens"=>0}
  def sendgrid_email_stats(email_id)

   uri = "http://sendgrid.com/api/stats.get.json?aggregate=1&category=#{email_id}&api_user=#{AppConstants.sendgrid_api_user}&api_key=#{AppConstants.sendgrid_api_password}"

    # SendGrid returns a list, so unwrap the single element in that list.
    JSON.parse(Net::HTTP.get(URI.parse(uri)))[0]
  end

end
<commit_msg>Fix typo<commit_after>require 'uri'
require 'net/http'
require 'json'

module SendgridHelper
  # Get stats associated with an email from SendGrid
  #
  # Returns a hash of numbers like
  #
  #  {"delivered"=>0, "unsubscribes"=>0, "name"=>"email_1000",
  #  "invalid_email"=>0, "bounces"=>0, "repeat_unsubscribes"=>0,
  #  "unique_clicks"=>0, "spam_drop"=>0, "repeat_bounces"=>0,
  #  "repeat_spamreports"=>0, "blocked"=>0, "requests"=>0,
  #  "spamreports"=>0, "clicks"=>0, "opens"=>0, "unique_opens"=>0}
  def sendgrid_email_stats(email_id)

   uri = "http://sendgrid.com/api/stats.get.json?aggregate=1&category=#{email_id}&api_user=#{AppConstants.sendgrid_api_username}&api_key=#{AppConstants.sendgrid_api_password}"

    # SendGrid returns a list, so unwrap the single element in that list.
    JSON.parse(Net::HTTP.get(URI.parse(uri)))[0]
  end

end

{'fraction_non_alphanumeric': 0.17554125219426564, 'fraction_numerical': 0.024575775307197192, 'mean_word_length': 5.84, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '5976665', 'n_tokens_mistral': 685, 'n_tokens_neox': 662, 'n_words': 115}