<commit_before>require 'json'
class LogsController < ApplicationController
  skip_before_filter :require_login, only: [:create]
  def create
    begin
      data = convert_hash_keys_to_symbols(JSON.parse(params[:data]))
      app = Application.find_by!(api_key: data[:api_key])
      if app.logs.build_from_api(data).save!
        render nothing: true, status: 200
      end
    rescue ActiveRecord::RecordNotFound
      render nothing: true, status: 401
    rescue TypeError, ActiveRecord::RecordInvalid
      render nothing: true, status: 400
    end
  end


  private
  def convert_hash_keys_to_symbols(hash)
    Hash[hash.map{ |k, v| [k.to_sym, v] }]
  end

  def render_400
    render nothing: true, status: 400
  end
end<commit_msg>Removed a method that was no longer used<commit_after>require 'json'
class LogsController < ApplicationController
  skip_before_filter :require_login, only: [:create]
  def create
    begin
      data = convert_hash_keys_to_symbols(JSON.parse(params[:data]))
      app = Application.find_by!(api_key: data[:api_key])
      if app.logs.build_from_api(data).save!
        render nothing: true, status: 200
      end
    rescue ActiveRecord::RecordNotFound
      render nothing: true, status: 401
    rescue TypeError, ActiveRecord::RecordInvalid
      render nothing: true, status: 400
    end
  end

  private
  def convert_hash_keys_to_symbols(hash)
    Hash[hash.map{ |k, v| [k.to_sym, v] }]
  end
end
{'fraction_non_alphanumeric': 0.09097222222222222, 'fraction_numerical': 0.016666666666666666, 'mean_word_length': 3.7401315789473686, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1988773', 'n_tokens_mistral': 477, 'n_tokens_neox': 453, 'n_words': 118}