<commit_before>class Homeroom < ActiveRecord::Base
  extend FriendlyId
  friendly_id :slug_candidates, use: :slugged
  validates :name, presence: true, uniqueness: { scope: [:name, :school] }
  validates :slug, uniqueness: true, presence: true
  validates :school, presence: true
  has_many :students, after_add: :update_grade
  has_many :student_risk_levels, through: :students
  belongs_to :educator
  belongs_to :school

  def slug_candidates
    [ :name, school.try(:local_id) ]
  end

  def update_grade(student)
    # Set homeroom grade level to be first student's grade level, since
    # we don't have any crosswalk between homerooms and grades in
    # Somerville's Student Information System

    return if self.grade.present?
    return if student.grade.blank?
    update_attribute(:grade, student.grade)<commit_msg>Make sure we have 'homeroom' in the homeroom slug<commit_after>class Homeroom < ActiveRecord::Base
  extend FriendlyId
  friendly_id :slug_candidates, use: :slugged
  validates :name, presence: true, uniqueness: { scope: [:name, :school] }
  validates :slug, uniqueness: true, presence: true
  validates :school, presence: true
  has_many :students, after_add: :update_grade
  has_many :student_risk_levels, through: :students
  belongs_to :educator
  belongs_to :school

  def slug_candidates
    [ :name, school.try(:local_id) + '-homeroom' ]
  end

  def update_grade(student)
    # Set homeroom grade level to be first student's grade level, since
    # we don't have any crosswalk between homerooms and grades in
    # Somerville's Student Information System

    return if self.grade.present?
    return if student.grade.blank?
    update_attribute(:grade, student.grade)
{'fraction_non_alphanumeric': 0.08450704225352113, 'fraction_numerical': 0.0, 'mean_word_length': 4.571895424836601, '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': '5592948', 'n_tokens_mistral': 542, 'n_tokens_neox': 521, 'n_words': 166}