<commit_before>class Course < ActiveRecord::Base
  has_many :course_instances, dependent: :destroy

  scope :search, ->(q) { where("concat(lower(department), course_number) like ?
                               OR lower(title) like ?",
                               "%#{q.to_s.downcase.gsub(/\s+/,'')}%", "%#{q.to_s.downcase}%") }

  # Get all prereq info from the database.
  # Return an array of arrays of courses.
  def prerequisites
    Prerequisite.where(postrequisite: self).map do |prereq|
      Course.where(id: prereq.prerequisite_ids)
    end
  end

  def postrequisites
    Course.where(id: Prerequisite.where('? = ANY(prerequisite_ids)', id).pluck(:postrequisite_id))
  end

  def schedulable?
    course_instances.any? { |course_instance| course_instance.try(:schedulable?) }
  end

  def to_param
    "#{department}#{course_number}"
  end

  def to_s
    "#{department} #{course_number}"
  end

  def long_string
    "#{to_s}: #{title}"
  end
end
<commit_msg>fixes search bug found by @cgutman.<commit_after>class Course < ActiveRecord::Base
  has_many :course_instances, dependent: :destroy

  scope :search, ->(q) { where("concat(lower(courses.department), courses.course_number) like ?
                               OR lower(courses.title) like ?",
                               "%#{q.to_s.downcase.gsub(/\s+/,'')}%", "%#{q.to_s.downcase}%") }

  # Get all prereq info from the database.
  # Return an array of arrays of courses.
  def prerequisites
    Prerequisite.where(postrequisite: self).map do |prereq|
      Course.where(id: prereq.prerequisite_ids)
    end
  end

  def postrequisites
    Course.where(id: Prerequisite.where('? = ANY(prerequisite_ids)', id).pluck(:postrequisite_id))
  end

  def schedulable?
    course_instances.any? { |course_instance| course_instance.try(:schedulable?) }
  end

  def to_param
    "#{department}#{course_number}"
  end

  def to_s
    "#{department} #{course_number}"
  end

  def long_string
    "#{to_s}: #{title}"
  end
end

{'fraction_non_alphanumeric': 0.13490471414242727, 'fraction_numerical': 0.0, 'mean_word_length': 3.15625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1416252', 'n_tokens_mistral': 706, 'n_tokens_neox': 671, 'n_words': 145}