<commit_before>module EventBright
  
  class Discount < ApiObject
    
    updatable :code
    updatable :amount_off, :percent_off 
    updatable :tickets 
    updatable :quantity_available
    updatable_date :start_date, :end_date
    readable :quantity_sold
    
    requires :code
    
    # Tickets can't live outside events, so we override standard owner to be event.
    def initialize(event = nil, hash = {})
      preinit
      raise ArgumentError unless event.is_a? EventBright::Event
      @id = hash.delete(:id)
      @event = event
      @owner = event.owner
      init_with_hash(hash, true)
    end
    
    def discount_id=(val, no_dirty = false)
      id = val
    end
    
    def new_hash
      {:event_id => @event.id}
    end
    
    
    def after_new
      @event.dirty_discounts!
    end
    
    def after_save
      @event.dirty_discounts!
    end
    
    def after_attribute_set
      @event.dirty_discounts! unless @event.nil?
    end
    
    def amount_off=(val, no_dirty = false)
      attribute_set(:amount_off, val, no_dirty)
      attribute_set(:percent_off, "", no_dirty)
    end<commit_msg>Fix discount ids<commit_after>module EventBright
  
  class Discount < ApiObject
    
    updatable :code
    updatable :amount_off, :percent_off 
    updatable :tickets 
    updatable :quantity_available
    updatable_date :start_date, :end_date
    readable :quantity_sold
    
    requires :code
    
    # Tickets can't live outside events, so we override standard owner to be event.
    def initialize(event = nil, hash = {})
      preinit
      raise ArgumentError unless event.is_a? EventBright::Event
      @id = hash.delete(:id)
      @event = event
      @owner = event.owner
      init_with_hash(hash, true)
    end
    
    def discount_id=(val, no_dirty = false)
      self.id = val
    end
    
    def new_hash
      {:event_id => @event.id}
    end
    
    
    def after_new
      @event.dirty_discounts!
    end
    
    def after_save
      @event.dirty_discounts!
    end
    
    def after_attribute_set
      @event.dirty_discounts! unless @event.nil?
    end
    
    def amount_off=(val, no_dirty = false)
      attribute_set(:amount_off, val, no_dirty)
      attribute_set(:percent_off, "", no_dirty)
    end
{'fraction_non_alphanumeric': 0.07654867256637168, 'fraction_numerical': 0.0, 'mean_word_length': 2.3746268656716416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3418803', 'n_tokens_mistral': 745, 'n_tokens_neox': 732, 'n_words': 179}