<commit_before>class Ranking < ActiveRecord::Base
  belongs_to :website
  belongs_to :community
  
  # Store this ranking record in past_rankings table:
  
  def archive
    
    pr = PastRanking.create!({:ranking_id => self.id, :community_id => self.community_id, :website_id => self.website_id,
                              :rank => self.rank, :ranking_updated_at => self.updated_at, :share => self.share,
                              :status => self.status, :count0 => self.count0, :count1 => self.count1})
    
    @fundings = Funding.find(:all, :conditions => ["date = ? AND allocated < ?", Date.today, 100])
    if @fundings
      @fundings.each do |funding|
        if funding.community_id == pr.community_id
          funding.allocated += pr.share
          pr.funds += funding.amount
          pr.award += funding.amount * pr.share / 100.0
          funding.save
          pr.save
        end
      end
    end
    
  end<commit_msg>Respond appropriately once a funding is 100% allocated: After that, a 0% share is OK but a positive share is not OK.<commit_after>class Ranking < ActiveRecord::Base
  belongs_to :website
  belongs_to :community
  
  # Store this ranking record in past_rankings table:
  
  def archive
    
    pr = PastRanking.create!({:ranking_id => self.id, :community_id => self.community_id, :website_id => self.website_id,
                              :rank => self.rank, :ranking_updated_at => self.updated_at, :share => self.share,
                              :status => self.status, :count0 => self.count0, :count1 => self.count1})
    
    if @fundings = Funding.find(:all, :conditions => ["date = ? AND community_id = ?", Date.today, pr.community_id])
      @fundings.each do |funding|
        
        if funding.allocated + pr.share <= 100.0
          funding.allocated += pr.share
          pr.funds += funding.amount
          pr.award += funding.amount * pr.share / 100.0
          funding.save
          pr.save
        else
          puts "Tried to allocate over 100% of funding ID " + funding.id.to_s
        end
        
      end
    end
    
  end
{'fraction_non_alphanumeric': 0.11005240590757503, 'fraction_numerical': 0.014292520247737018, 'mean_word_length': 2.1296572280178836, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '5484636', 'n_tokens_mistral': 662, 'n_tokens_neox': 626, 'n_words': 161}