<commit_before>class UsersController < ApplicationController
  def show
    user = User.find_by(id: params[:id])

    if user
      searches = user.searches
      searched_products = user.products
      saved_product_ids = user.searches.where(is_saved: true).pluck(:product_id)
      saved_products = Product.find(saved_product_ids)

      render json: {
        found: true,
        user: user,
        searches: searches,
        searched_products: searched_products,
        saved_products: saved_products
      }.to_json
    else
      render json: { found: false }.to_json
    end
  end

  def create
    user = User.new(email: params[:email], password: params[:password])
    if user.save
      render json: {
        saved: true,
        user: user
      }.to_json
    else
      render json: {
        saved: false,
        errors: user.errors.full_messages
      }.to_json<commit_msg>Add user grade to JSON output for user show method<commit_after>class UsersController < ApplicationController
  def show
    user = User.find_by(id: params[:id])

    if user
      searches = user.searches
      searched_products = user.products
      saved_product_ids = user.searches.where(is_saved: true).pluck(:product_id)
      saved_products = Product.find(saved_product_ids)

      render json: {
        found: true,
        user: user,
        user_grade: user.grade,
        searches: searches,
        searched_products: searched_products,
        saved_products: saved_products
      }.to_json
    else
      render json: { found: false }.to_json
    end
  end

  def create
    user = User.new(email: params[:email], password: params[:password])
    if user.save
      render json: {
        saved: true,
        user: user
      }.to_json
    else
      render json: {
        saved: false,
        errors: user.errors.full_messages
      }.to_json
{'fraction_non_alphanumeric': 0.08571428571428572, 'fraction_numerical': 0.0, 'mean_word_length': 2.3806921675774135, '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': '3307450', 'n_tokens_mistral': 554, 'n_tokens_neox': 551, 'n_words': 138}