<commit_before>class Entry < ActiveRecord::Base
  validates :course, format: {with: /\A[A-Z]{2}[0-9]{3}[A-Z]\Z/, message: 'is not in the right format. Use something like IT334G.'}
  validates :name, uniqueness: {scope: [:course, :closed_at], case_sensitive: false, message: 'needs to be unique for the course (You cannot queue twice).'}, presence: true
  validates :room, format: {with: /\A[A-Z][0-9]{3}\Z/, message: 'is not in the right format. Use something like D204.'}
  validates :group, inclusion: {in: 1..20, message: 'needs to be between 1 and 20.'}
  validates :demonstration, inclusion: {in: [true, false], message: 'needs to be present.'}

  before_validation :convert_fields_to_uppercase

  def self.course(coursecode)
    where(course: coursecode)
  end

  def self.open
    where("entries.closed_at IS NULL" )
  end

  def self.closed
    where("entries.closed_at IS NOT NULL" )
  end

  def close
    self.closed_at = Time.now
    self.save
  end

  private
    def convert_fields_to_uppercase
      course.upcase!
      room.upcase!
    end
end<commit_msg>Anonymize all entries when they are closed<commit_after>class Entry < ActiveRecord::Base
  validates :course, format: {with: /\A[A-Z]{2}[0-9]{3}[A-Z]\Z/, message: 'is not in the right format. Use something like IT334G.'}
  validates :name, uniqueness: {scope: [:course, :closed_at], case_sensitive: false, message: 'needs to be unique for the course (You cannot queue twice).'}, presence: true
  validates :room, format: {with: /\A[A-Z][0-9]{3}\Z/, message: 'is not in the right format. Use something like D204.'}
  validates :group, inclusion: {in: 1..20, message: 'needs to be between 1 and 20.'}
  validates :demonstration, inclusion: {in: [true, false], message: 'needs to be present.'}

  before_validation :convert_fields_to_uppercase

  def self.course(coursecode)
    where(course: coursecode)
  end

  def self.open
    where("entries.closed_at IS NULL" )
  end

  def self.closed
    where("entries.closed_at IS NOT NULL" )
  end

  def close
    self.closed_at = Time.now
    self.name = 'Anonymized'
    self.save
  end

  private
    def convert_fields_to_uppercase
      course.upcase!
      room.upcase!
    end
end
{'fraction_non_alphanumeric': 0.12443233424159855, 'fraction_numerical': 0.01725703905540418, 'mean_word_length': 3.7376344086021507, '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': '874620', 'n_tokens_mistral': 766, 'n_tokens_neox': 723, 'n_words': 237}