<commit_before>class PlansController < ApplicationController
  before_action :set_plan, only: [:show, :edit, :update, :destroy]
  before_action :set_classroom, only: [:new, :index]

  rescue_from PlanGenerator::NoPlanFound, with: :no_plan_found

  def no_plan_found
    redirect_to classroom_path(@classroom), alert: "Unable to generate a new plan for this classroom. Please try adding another bag."
  end

  # GET /plans
  # GET /plans.json
  def index
    @plans = @classroom.plans
  end

  # GET /plans/1
  # GET /plans/1.json
  def show
  end

  # GET /classrooms/:classroom_id/plans/new
  def new
    name = Time.now.strftime("%Y-%m-%d")
    @plan = Plan.new classroom: @classroom, name: name
    pg = PlanGenerator.new(@classroom.eligible_students, @classroom.available_book_bags)
    assignments = pg.generate
    assignments.sort_by!{ |a| a.student.first_name }<commit_msg>Log NoPlanFound exception to logs.:<commit_after>class PlansController < ApplicationController
  before_action :set_plan, only: [:show, :edit, :update, :destroy]
  before_action :set_classroom, only: [:new, :index]

  rescue_from PlanGenerator::NoPlanFound, with: :no_plan_found

  def no_plan_found(e)
    Rails.logger.info(<<-MSG
                      #{e.message}
                      No plan found.
                      #{e.backtrace.join("\n")}
                      MSG
                     )
    redirect_to classroom_path(@classroom), alert: "Unable to generate a new plan for this classroom. Please try adding another bag."
  end

  # GET /plans
  # GET /plans.json
  def index
    @plans = @classroom.plans
  end

  # GET /plans/1
  # GET /plans/1.json
  def show
  end

  # GET /classrooms/:classroom_id/plans/new
  def new
    name = Time.now.strftime("%Y-%m-%d")
    @plan = Plan.new classroom: @classroom, name: name
    pg = PlanGenerator.new(@classroom.eligible_students, @classroom.available_book_bags)
    assignments = pg.generate
    assignments.sort_by!{ |a| a.student.first_name }
{'fraction_non_alphanumeric': 0.11183879093198992, 'fraction_numerical': 0.0020151133501259445, 'mean_word_length': 3.078028747433265, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4650624', 'n_tokens_mistral': 663, 'n_tokens_neox': 648, 'n_words': 161}