<commit_before>class Performance < ActiveRecord::Base
  belongs_to :show
  belongs_to :venue
  has_many :tickets
  attr_accessible :date, :show_id, :venue_id, :price
  validates_presence_of :date
  validates_presence_of :venue_id
  validates_presence_of :price

  def price_string
      return "$%d.%02d" %  [self.price / 100, self.price % 100]
  end
  def date_string
      return self.date.strftime('%l:%M%p - %b %e')
  end
  def sold_out?
      return self.quantity_sold >= self.venue.capacity
  end
  def quantity_sold
      total = 0
      self.tickets.includes(:cart).collect { |t| total =+ t.quantity if t.cart.placed_at? }
      total
  end
  def quantity_remaining
      self.venue.capacity - self.quantity_sold
  end
end
<commit_msg>fixed bug in quantity sold calculation<commit_after>class Performance < ActiveRecord::Base
  belongs_to :show
  belongs_to :venue
  has_many :tickets
  attr_accessible :date, :show_id, :venue_id, :price
  validates_presence_of :date
  validates_presence_of :venue_id
  validates_presence_of :price

  def price_string
      return "$%d.%02d" %  [self.price / 100, self.price % 100]
  end
  def date_string
      return self.date.strftime('%l:%M%p - %b %e')
  end
  def sold_out?
      return self.quantity_sold >= self.venue.capacity
  end
  def quantity_sold
      total = 0
      self.tickets.each do |t|
          if t.cart.purchased_at?
              total += t.quantity
          end
      end
      total
  end
  def quantity_remaining
      self.venue.capacity - self.quantity_sold
  end
end

{'fraction_non_alphanumeric': 0.0907911802853437, 'fraction_numerical': 0.011673151750972763, 'mean_word_length': 3.0182291666666665, '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': '3678678', 'n_tokens_mistral': 561, 'n_tokens_neox': 527, 'n_words': 128}