<commit_before>class ReadingsController < ApplicationController
   protect_from_forgery except: :create

  def create
    reading = Reading.create_from_params(strong_params)

    if reading[:error]
      render json: reading, status: 500
    else
      render json: reading
    end
  end

  private

  def strong_params
    params.require(:reading).permit(:sensor_name, :temp, :time, :verification)
  end
end
<commit_msg>Return 400 instead of 500 on missing sensor or user<commit_after>class ReadingsController < ApplicationController
   protect_from_forgery except: :create

  def create
    reading = Reading.create_from_params(strong_params)

    if reading[:error]
      render json: reading, status: 400
    else
      render json: reading
    end
  end

  private

  def strong_params
    params.require(:reading).permit(:sensor_name, :temp, :time, :verification)
  end
end

{'fraction_non_alphanumeric': 0.07045454545454545, 'fraction_numerical': 0.013636363636363636, 'mean_word_length': 3.840659340659341, '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': '4213368', 'n_tokens_mistral': 270, 'n_tokens_neox': 247, 'n_words': 73}