<commit_before>class HomeroomsController < ApplicationController
  include StudentsQueryHelper

  # Authentication by default inherited from ApplicationController.

  before_action :authorize_and_assign_homeroom

  def show
    cookies[:columns_selected] ||= initial_columns.to_json

    @rows = eager_students().map {|student| fat_student_hash(student) }

    # Risk level chart
    @risk_levels = @homeroom.student_risk_levels.group(:level).count
    @risk_levels['null'] = if @risk_levels.has_key? nil then @risk_levels[nil] else 0 end

    # Dropdown for homeroom navigation
    @homerooms_by_name = current_educator.allowed_homerooms_by_name

    # For links to STAR pages
    @school_id = @homeroom.students.map(&:school_id).uniq.first # should be only one
    @star_homeroom_anchor = "equal:homeroom_name:#{@homeroom.name}"
  end

  private

  def initial_columns
    return ['name', 'risk', 'sped', 'mcas_math', 'mcas_ela', 'interventions'] if @homeroom.show_mcas?
    return ['name', 'risk', 'sped', 'interventions']
  end

  def eager_students(*additional_includes)
    @homeroom.students.includes([
      :interventions,
      :student_risk_level,<commit_msg>Only pull active students into the Homerooms view<commit_after>class HomeroomsController < ApplicationController
  include StudentsQueryHelper

  # Authentication by default inherited from ApplicationController.

  before_action :authorize_and_assign_homeroom

  def show
    cookies[:columns_selected] ||= initial_columns.to_json

    @rows = eager_students().map {|student| fat_student_hash(student) }

    # Risk level chart
    @risk_levels = @homeroom.student_risk_levels.group(:level).count
    @risk_levels['null'] = if @risk_levels.has_key? nil then @risk_levels[nil] else 0 end

    # Dropdown for homeroom navigation
    @homerooms_by_name = current_educator.allowed_homerooms_by_name

    # For links to STAR pages
    @school_id = @homeroom.students.active.map(&:school_id).uniq.first
    @star_homeroom_anchor = "equal:homeroom_name:#{@homeroom.name}"
  end

  private

  def initial_columns
    return ['name', 'risk', 'sped', 'mcas_math', 'mcas_ela', 'interventions'] if @homeroom.show_mcas?
    return ['name', 'risk', 'sped', 'interventions']
  end

  def eager_students(*additional_includes)
    @homeroom.students.active.includes([
      :interventions,
      :student_risk_level,
{'fraction_non_alphanumeric': 0.10341916420430561, 'fraction_numerical': 0.0008442380751371887, 'mean_word_length': 4.880893300248139, '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': '6424705', 'n_tokens_mistral': 801, 'n_tokens_neox': 750, 'n_words': 158}