<commit_before>class Users::ReviewsController < ApplicationController
  def index
    @users = User.all.decorate
  end

  def edit
    @review = Review.find(params[:id]).decorate
  end

  def show
    @review = Review.find(params[:id]).decorate
    @comment = Comment.build_from(@review, current_user.id, nil)
  end

  def update
    updated_review_params = update_if_level_only_review(update_status(review_params))

    @review = Review.find(params[:id])
    @review.assign_attributes(updated_review_params)

    if @review.save
      redirect_to :root, notice: 'Review saved successfully!'
    else
      render :edit
    end
  end

  private

  def update_if_level_only_review(review_params)
    if review_params[:text].strip.blank? && !review_params[:suggested_level].blank?
      review_params.merge!(is_level_only: true)
    end

    review_params
  end<commit_msg>Undo is_only_level to false if text is written<commit_after>class Users::ReviewsController < ApplicationController
  def index
    @users = User.all.decorate
  end

  def edit
    @review = Review.find(params[:id]).decorate
  end

  def show
    @review = Review.find(params[:id]).decorate
    @comment = Comment.build_from(@review, current_user.id, nil)
  end

  def update
    updated_review_params = update_if_level_only_review(update_status(review_params))

    @review = Review.find(params[:id])
    @review.assign_attributes(updated_review_params)

    if @review.save
      redirect_to :root, notice: 'Review saved successfully!'
    else
      render :edit
    end
  end

  private

  def update_if_level_only_review(review_params)
    if review_params[:text].strip.blank? && !review_params[:suggested_level].blank?
      review_params.merge!(is_level_only: true)
    else
      review_params.merge!(is_level_only: false)
    end

    review_params
  end
{'fraction_non_alphanumeric': 0.09438079650845609, 'fraction_numerical': 0.0, 'mean_word_length': 3.9301075268817205, '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': '4658575', 'n_tokens_mistral': 584, 'n_tokens_neox': 565, 'n_words': 115}