<commit_before>class Ticket < ActiveRecord::Base
  attr_accessible :attendee, :event, :kind

  belongs_to :attendee
  belongs_to :event
  has_many :interactions, as: :interactable

  validates :attendee_id, presence: true
  validates :event_id, presence: true, uniqueness: { scope: :attendee_id }
  validates :kind, presence: true, inclusion: { in: Ticket::Kind::TYPES }

  before_validation :set_kind

  after_create :generate_woodpecker_password

  def set_kind
    self.kind ||= Ticket::Kind::REGULAR
    true
  end
  
  def woodpecker_password
    self.interactions.where(:key => 'woodpecker_password')
  end
  
  private
  
  def generate_woodpecker_password
    o =  [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten
    token = Digest::SHA1.hexdigest("#{self.id}#{(0...50).map{ o[rand(o.length)] }.join}#{Time.now()}")
    self.interactions.create :key => 'woodpecker_password', :value => token
  end

end
<commit_msg>Added fix to retrieve key<commit_after>class Ticket < ActiveRecord::Base
  attr_accessible :attendee, :event, :kind

  belongs_to :attendee
  belongs_to :event
  has_many :interactions, as: :interactable

  validates :attendee_id, presence: true
  validates :event_id, presence: true, uniqueness: { scope: :attendee_id }
  validates :kind, presence: true, inclusion: { in: Ticket::Kind::TYPES }

  before_validation :set_kind

  after_create :generate_woodpecker_password

  def set_kind
    self.kind ||= Ticket::Kind::REGULAR
    true
  end
  
  def woodpecker_password
    self.interactions.where(:key => 'woodpecker_password')
    self.interactions.where(:key => 'woodpecker_password').first['value']
  end
  
  private
  
  def generate_woodpecker_password
    o =  [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten
    token = Digest::SHA1.hexdigest("#{self.id}#{(0...50).map{ o[rand(o.length)] }.join}#{Time.now()}")
    self.interactions.create :key => 'woodpecker_password', :value => token
  end

end

{'fraction_non_alphanumeric': 0.14492753623188406, 'fraction_numerical': 0.004140786749482402, 'mean_word_length': 4.475920679886686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '6470009', 'n_tokens_mistral': 701, 'n_tokens_neox': 690, 'n_words': 136}