<commit_before>User.class_eval do
  attr_accessible :full_name, :website, :phone
  #validates :website, :url_format => true
  has_many :affiliate_earnings do
    def unpaid
      @unpaidEarnings ||= find(:all, {
        :select => "#{AffiliateEarning.table_name}.* ",
        :joins  => "JOIN #{Order.table_name} ON #{Order.table_name}.id = #{AffiliateEarning.table_name}.order_id ",
        :conditions => "#{Order.table_name}.state = 'complete' and #{AffiliateEarning.table_name}.status != 'paid'"
      })
    end
  end
  has_many :affiliate_credits do
    def unpaid
      @unpaidCredits ||= find(:all, :conditions => "status != 'paid'")
    end
  end
  def earnings_total
      @total_earnings||= self.affiliate_earnings.unpaid.sum(:amount)
  end
  def credits_total
      @total_credits ||= self.affiliate_credits.unpaid.sum(:amount)
  end
  def total_earnings
      self.earnings_total + self.credits_total
  end
  def website_url
    if website && !website.downcase.include?("http")
      "http://#{website}"
    else
      self.website
    end
  end
end<commit_msg>reverted earnings and credits calculation, sum funtcion is not working<commit_after>User.class_eval do
  attr_accessible :full_name, :website, :phone
  #validates :website, :url_format => true
  has_many :affiliate_earnings do
    def unpaid
      @unpaidEarnings ||= find(:all, {
        :select => "#{AffiliateEarning.table_name}.* ",
        :joins  => "JOIN #{Order.table_name} ON #{Order.table_name}.id = #{AffiliateEarning.table_name}.order_id ",
        :conditions => "#{Order.table_name}.state = 'complete' and #{AffiliateEarning.table_name}.status != 'paid'"
      })
    end
  end
  has_many :affiliate_credits do
    def unpaid
      @unpaidCredits ||= find(:all, :conditions => "status != 'paid'")
    end
  end
  def earnings_total
      total = 0
      self.affiliate_earnings.unpaid.each do |earning|
        total = total+earning.amount
      end
      total
  end
  def credits_total
      total = 0
      self.affiliate_credits.unpaid.each do |credit|
        total = total+credit.amount
      end
      total
  end
  def total_earnings
      self.earnings_total + self.credits_total
  end
  def website_url
    if website && !website.downcase.include?("http")
      "http://#{website}"
    else
      self.website
    end
  end
end
{'fraction_non_alphanumeric': 0.12086021505376345, 'fraction_numerical': 0.0008602150537634409, 'mean_word_length': 3.1168141592920353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4795196', 'n_tokens_mistral': 794, 'n_tokens_neox': 773, 'n_words': 164}