<commit_before>desc "Check for inconsistencies in users credits, and fix incorrect ones"
task :fix_credit => :environment do
  # User.includes(:backs).each do |user|
  #   user.
  # end

  total = 0
  negative = []
  negative_sum = 0
  User.all.each do |user|
    uc = user.credits
    ucc = user.calculate_credits
    if uc != ucc
      puts "Verificando #{user.id}: #{user.name}"
      puts "#{uc} != #{ucc}"
      total += 1
      if ucc < 0
        negative << user.id
        negative_sum += ucc
        user.update_attribute :credits, 0
      else
        user.update_attribute :credits, ucc
      end
    end
  end
  puts "total fixed: #{total}"<commit_msg>adjusts for fix_credits task<commit_after>desc "Check for inconsistencies in users credits, and fix incorrect ones"
task :fix_credits => :environment do
  # User.includes(:backs).each do |user|
  #   user.
  # end

  total = 0
  negative = []
  negative_sum = 0
  User.all.each do |user|
    uc = user.credits
    ucc = user.calculate_credits
    if uc != ucc
      puts "Verificando #{user.id}: #{user.name}"
      puts "#{uc} != #{ucc}"
      total += 1
      if ucc < 0
        negative << user.id
        negative_sum += ucc
      end
      user.update_attribute :credits, ucc
    end
  end
  puts "total fixed: #{total}"
{'fraction_non_alphanumeric': 0.11714507370054306, 'fraction_numerical': 0.0069821567106283944, 'mean_word_length': 2.4217506631299734, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2853690', 'n_tokens_mistral': 440, 'n_tokens_neox': 423, 'n_words': 128}