<commit_before>class Course < ActiveRecord::Base
  has_and_belongs_to_many :skills
  has_many :enrollments
  has_many :categories, -> { uniq }, through: :skills
  has_many :users, through: :enrollments

  validates_presence_of :name, :handle
  validates_uniqueness_of :handle

  scope :published, -> { where(status: :published) }

  state_machine :status, initial: :created do
    event :approve    { transition :created => :approved }
    event :publish    { transition [:created, :approved, :hidden] => :published }
    event :hide       { transition :published => :hidden }
    event :deprecate  { transition :published => :deprecated }
  end

  def self.available_to(student)
    admin_courses = student.admin? ? all : none
    (published | student.courses | admin_courses).sort_by(&:id)<commit_msg>whoops.<commit_after>class Course < ActiveRecord::Base
  has_and_belongs_to_many :skills
  has_many :enrollments
  has_many :categories, -> { uniq }, through: :skills
  has_many :users, through: :enrollments

  validates_presence_of :name, :handle
  validates_uniqueness_of :handle

  scope :published, -> { where(status: :published) }

  state_machine :status, initial: :created do
    event :approve    do transition :created => :approved end
    event :publish    do transition [:created, :approved, :hidden] => :published end
    event :hide       do transition :published => :hidden end
    event :deprecate  do transition :published => :deprecated end
  end

  def self.available_to(student)
    admin_courses = student.admin? ? all : none
    (published | student.courses | admin_courses).sort_by(&:id)
{'fraction_non_alphanumeric': 0.10856079404466501, 'fraction_numerical': 0.0, 'mean_word_length': 4.271241830065359, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1736029', 'n_tokens_mistral': 502, 'n_tokens_neox': 490, 'n_words': 131}