<commit_before>class PredictionsController < ApplicationController
  before_action :require_signed_in!, only: [:new, :create]

  def index
    @predictions = Prediction.all
    render :index
  end

  def undetermined
    @prediction_count = Prediction.count
    @predictions = Prediction.where('judged = ?', false).sort_by(&:deadline)

    render :undetermined
  end

  def new
    render :new
  end

  def create
    parsed_datetime = Prediction.parse_datetime(params[:prediction][:deadline])
    @prediction = Prediction.new
    @prediction.statement = params[:prediction][:statement]
    @prediction.deadline = parsed_datetime
    @prediction.user_id = current_user.id

    if @prediction.save
      redirect_to prediction_url(@prediction)
    else
      flash[:errors] = @prediction.errors.full_messages
      render :new
    end
  end

  def show
    @prediction = Prediction.find(params[:id])
    render :show
  end
end<commit_msg>refactor prediction controller create action<commit_after>class PredictionsController < ApplicationController
  before_action :require_signed_in!, only: [:new, :create]

  def index
    @predictions = Prediction.all
    render :index
  end

  def undetermined
    @prediction_count = Prediction.count
    @predictions = Prediction.where('judged = ?', false).sort_by(&:deadline)

    render :undetermined
  end

  def new
    render :new
  end

  def create
    @prediction = Prediction.new
    @prediction.statement = params[:prediction][:statement]
    @prediction.deadline = Prediction.parse_datetime(params[:prediction][:deadline])
    @prediction.user_id = current_user.id

    if @prediction.save
      redirect_to prediction_url(@prediction)
    else
      flash[:errors] = @prediction.errors.full_messages
      render :new
    end
  end

  def show
    @prediction = Prediction.find(params[:id])
    render :show
  end
end
{'fraction_non_alphanumeric': 0.09373326191751473, 'fraction_numerical': 0.0, 'mean_word_length': 3.7411167512690353, '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': '2480913', 'n_tokens_mistral': 581, 'n_tokens_neox': 557, 'n_words': 123}