<commit_before>class ReflectionsController < ApplicationController
  before_action :authenticate_user!

  def new
    if Reflection.today(current_user).present?
      flash[:error] = 'You already wrote your reflection for today.'
      redirect_to dashboard_path
    elsif TodoList.today(current_user).blank?
      flash[:error] = 'You must start your tasks for today before writing a reflection.'
      redirect_to dashboard_path
    end

    @reflection = Reflection.new
    @todo_list = TodoList.today(current_user)
  end

  def create
    @reflection = Reflection.new(reflection_params)
    @reflection.user = current_user
    @reflection.date = Date.current

    if @reflection.save
      redirect_to tomorrow_path
    else
      render :new
    end
  end

  private

  def reflection_params
    params.require(:reflection).permit(:rating, :right, :wrong, :undone)
  end
end<commit_msg>Set todo list.<commit_after>class ReflectionsController < ApplicationController
  before_action :authenticate_user!

  def new
    if Reflection.today(current_user).present?
      flash[:error] = 'You already wrote your reflection for today.'
      redirect_to dashboard_path
    elsif TodoList.today(current_user).blank?
      flash[:error] = 'You must start your tasks for today before writing a reflection.'
      redirect_to dashboard_path
    end

    @reflection = Reflection.new
    @todo_list = TodoList.today(current_user)
  end

  def create
    @reflection = Reflection.new(reflection_params)
    @reflection.user = current_user
    @reflection.date = Date.current

    if @reflection.save
      redirect_to tomorrow_path
    else
      @todo_list = TodoList.today(current_user)
      render :new
    end
  end

  private

  def reflection_params
    params.require(:reflection).permit(:rating, :right, :wrong, :undone)
  end
end
{'fraction_non_alphanumeric': 0.0764609503003823, 'fraction_numerical': 0.0, 'mean_word_length': 3.5346534653465347, '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': '4216573', 'n_tokens_mistral': 560, 'n_tokens_neox': 532, 'n_words': 137}