<commit_before>class GiftCard < ActiveRecord::Base

  monetize :amount_cents

  enum reason: {
    unknown: 0,
    signup: 1,
    test: 2,
    referral: 3,
    interview: 4,
    other: 5
  }

  belongs_to :giftable, polymorphic: true, touch: true
  belongs_to :person
  belongs_to :user
  validates_presence_of :amount
  validates_presence_of :reason
  validates_format_of :expiration_date, with: /\A(0|1)([0-9])\/(2[0-9]{3})\z/i

  # Need to add validation to limit 1 signup per person

end
<commit_msg>validating the uniqueness of only one signup gift card<commit_after>class GiftCard < ActiveRecord::Base

  monetize :amount_cents

  enum reason: {
    unknown: 0,
    signup: 1,
    test: 2,
    referral: 3,
    interview: 4,
    other: 5
  }

  belongs_to :giftable, polymorphic: true, touch: true
  belongs_to :person
  belongs_to :user
  validates_presence_of :amount
  validates_presence_of :reason
  validates_format_of :expiration_date, with: /\A(0|1)([0-9])\/(2[0-9]{3})\z/i

  validates_uniqueness_of :reason, scope: :person_id if -> { reason == 'signup' }
  # Need to add validation to limit 1 signup per person

end

{'fraction_non_alphanumeric': 0.10786914235190097, 'fraction_numerical': 0.026525198938992044, 'mean_word_length': 3.6970954356846475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '3064030', 'n_tokens_mistral': 441, 'n_tokens_neox': 413, 'n_words': 111}