<commit_before>class Lab < ActiveRecord::Base
  belongs_to :lab_description
  belongs_to :given_course

  has_many :lab_has_groups
  has_many :lab_groups, through: :lab_has_groups
  has_many :submissions
  has_many :default_deadlines, inverse_of: :lab

  has_one :initial_lab_commit_for_lab
  has_one :initial_lab_commit, through: :initial_lab_commit_for_lab

  validates_presence_of :lab_description, :given_course, :number
  validates_uniqueness_of :lab_description_id, scope: :given_course_id
  scope :not_finished, joins(:lab_has_groups).where("lab_has_groups.grade IS NULL")
  scope :finished, joins(:lab_has_groups).where("lab_has_groups.grade IS NOT NULL")
  
  accepts_nested_attributes_for :default_deadlines
  validates_presence_of :default_deadlines

  acts_as_list scope: :given_course, column: :number

  default_scope where("labs.active = ?", true)
  
  #
  # Adds a lab-group to the lab
  # Creates lab_has_group and repository
  #
  def add_group(lab_group)
    @repository = Repository.create()
    @lab_has_group = LabHasGroup.create(
      lab_group: lab_group, 
      lab: self, 
      repository: @repository
    )
  end

  #
  # Implements #title and #description
  #
  def method_missing(meth, *args, &blk)
    if lab_description and lab_description.respond_to?(meth)
      return lab_description.send(meth, *args)
    end

    super
  end
end<commit_msg>Should use create band-method in order to raise errors<commit_after>class Lab < ActiveRecord::Base
  belongs_to :lab_description
  belongs_to :given_course

  has_many :lab_has_groups
  has_many :lab_groups, through: :lab_has_groups
  has_many :submissions
  has_many :default_deadlines, inverse_of: :lab

  has_one :initial_lab_commit_for_lab
  has_one :initial_lab_commit, through: :initial_lab_commit_for_lab

  validates_presence_of :lab_description, :given_course, :number
  validates_uniqueness_of :lab_description_id, scope: :given_course_id
  scope :not_finished, joins(:lab_has_groups).where("lab_has_groups.grade IS NULL")
  scope :finished, joins(:lab_has_groups).where("lab_has_groups.grade IS NOT NULL")
  
  accepts_nested_attributes_for :default_deadlines
  validates_presence_of :default_deadlines

  acts_as_list scope: :given_course, column: :number

  default_scope where("labs.active = ?", true)
  
  #
  # Adds a lab-group to the lab
  # Creates lab_has_group and repository
  #
  def add_group(lab_group)
    @repository = Repository.create()
    @lab_has_group = LabHasGroup.create!(
      lab_group: lab_group, 
      lab: self, 
      repository: @repository
    )
  end

  #
  # Implements #title and #description
  #
  def method_missing(meth, *args, &blk)
    if lab_description and lab_description.respond_to?(meth)
      return lab_description.send(meth, *args)
    end

    super
  end
end
{'fraction_non_alphanumeric': 0.08077197998570407, 'fraction_numerical': 0.0, 'mean_word_length': 4.783057851239669, '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': '461044', 'n_tokens_mistral': 967, 'n_tokens_neox': 936, 'n_words': 203}