<commit_before>class Event < ActiveRecord::Base
  #set_primary_keys :day
  validates :day, :activity_id, :description, :presence => true
  
  attr_accessible :day, :activity_id, :description
  
  def self.replace(day, activity_id, description)
    return nil if day.blank?

    e = Event.find_by_day(day)
    if e.nil?
      e = Event.new #TODO .create doesn't work?
      e.day = day
    end
    e.activity_id = activity_id #there is only one activity per day
    e.description = description
    e.save
    
    e
  end
end
<commit_msg>events has a proper primary key<commit_after>class Event < ActiveRecord::Base
  validates :day, :activity_id, :description, :presence => true
  validates :day, :uniqueness => true
  
  attr_accessible :day, :activity_id, :description
  
  def self.replace(day, activity_id, description)
    return nil if day.blank?

    e = Event.find_by_day(day)
    if e.nil?
      e = Event.new #TODO .create doesn't work?
      e.day = day
    end
    e.activity_id = activity_id #there is only one activity per day
    e.description = description
    e.save
    
    e
  end
end

{'fraction_non_alphanumeric': 0.09140271493212669, 'fraction_numerical': 0.0, 'mean_word_length': 2.9927797833935017, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '5960579', 'n_tokens_mistral': 369, 'n_tokens_neox': 362, 'n_words': 109}