<commit_before>class GiftCode < ActiveRecord::Base
  belongs_to :user

  validates :code, uniqueness: true, presence: true
  validates :months, presence: true

  before_validation :generate_code

  def generate_code
    if self.code.nil?
    	loop do
    	  self.code = SecureRandom.hex(4)
        break if GiftCode.where(code: self.code).empty?
      end
  	end
  end

  def purchaser_first_name
    purchaser_name ? purchaser_name.split(' ',2)[0] : ''
  end
  
  def purchaser_last_name
    purchaser_name ? purchaser_name.split(' ',2)[1] : ''
  end
  
  def price
    GiftCode.prices[months]
  end
  
  def description
    "#{months} month subscription"
  end
  
  def self.prices
    {
      3  => 18.00,
      6  => 34.20,
      9  => 48.60,
      12 => 61.20,
    }
  end

end
<commit_msg>use gift code itself in URL, not id<commit_after>class GiftCode < ActiveRecord::Base
  belongs_to :user

  validates :code, uniqueness: true, presence: true
  validates :months, presence: true

  before_validation :generate_code

  def to_param
    code
  end
  
  def generate_code
    if self.code.nil?
    	loop do
    	  self.code = SecureRandom.hex(4)
        break if GiftCode.where(code: self.code).empty?
      end
  	end
  end

  def purchaser_first_name
    purchaser_name ? purchaser_name.split(' ',2)[0] : ''
  end
  
  def purchaser_last_name
    purchaser_name ? purchaser_name.split(' ',2)[1] : ''
  end
  
  def price
    GiftCode.prices[months]
  end
  
  def description
    "#{months} month subscription"
  end
  
  def self.prices
    {
      3  => 18.00,
      6  => 34.20,
      9  => 48.60,
      12 => 61.20,
    }
  end

end

{'fraction_non_alphanumeric': 0.10030395136778116, 'fraction_numerical': 0.031610942249240125, 'mean_word_length': 2.4363256784968685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2095571', 'n_tokens_mistral': 633, 'n_tokens_neox': 584, 'n_words': 143}