<commit_before>if (local_gem_dir = File.join(File.dirname(__FILE__), '..', '..', 'gems')) && $BUNDLE.nil?
  $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
end
Merb.start_environment(:environment => ENV['MERB_ENV'] || 'production')

namespace :mostfit do
  desc "Update history of all loans"
  task :eod  do
    loan_ids = Payment.all(:received_on => Date.today - 1).map{|l| l.loan_id}.compact.uniq
    puts loan_ids.count
    
    loan_ids.each{|lid|
      puts lid
      Loan.get(lid).update_history
    }
  end
end<commit_msg>fixed EOD for payments created today rather than received for today<commit_after>if (local_gem_dir = File.join(File.dirname(__FILE__), '..', '..', 'gems')) && $BUNDLE.nil?
  $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
end
Merb.start_environment(:environment => ENV['MERB_ENV'] || 'production')

namespace :mostfit do
  desc "Update history of all loans"
  task :eod  do
    loan_ids = Payment.all(:created_at.gte => Date.today - 1).map{|l| l.loan_id}.compact.uniq
    puts loan_ids.count
    
    loan_ids.each{|lid|
      puts lid
      Loan.get(lid).update_history
    }

    data1 = repository.adapter.query("select loan_id, max(created_at) as date from loan_history lh where 1 group by lh.loan_id").map{|x| 
      [x.loan_id, x.date]
    }.to_hash
    data2 = repository.adapter.query("select p.loan_id, max(p.created_at) as date from payments p where deleted_at is NULL group by p.loan_id").map{|x| 
      [x.loan_id, x.date]
    }.to_hash
    problems = []
    data1.each{|lid, date| problems << lid if data2[lid] and (data2[lid] - date ) >0}
    problems.eahc{|lid|
      Loan.get(lid).update_history
      puts lid
    }
  end
end
{'fraction_non_alphanumeric': 0.14252199413489736, 'fraction_numerical': 0.005278592375366569, 'mean_word_length': 3.5251989389920424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '900088', 'n_tokens_mistral': 652, 'n_tokens_neox': 630, 'n_words': 136}