<commit_before>desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
  Configuration.update_configurations!
  #Project.finish_projects!
  #Project.send_reminders!
end

desc "Move to deleted state all backers that are in pending a lot of time"
task :move_pending_backers_to_trash => [:environment] do
  Backer.where("state in('pending') and created_at + interval '6 days' < current_timestamp").update_all({state: 'deleted'})
end

desc "Cancel all waiting_confirmation backers that is passed 4 weekdays"
task :cancel_expired_waiting_confirmation_backers => :environment do
  Backer.can_cancel.update_all(state: 'canceled')
end

desc "Send notification about credits 1 month after the project failed"
task send_credits_notification: :environment do
  Backer.send_credits_notification
end

desc "Create first versions for rewards"
task :index_rewards_versions => :environment do
  Reward.all.each do |reward|
    unless reward.versions.count > 0
      puts "update! #{reward.id}"
      reward.update_attributes(reindex_versions: DateTime.now)
    end
  end
end

desc "Update video_embed_url column"<commit_msg>Cron job added again<commit_after>desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
  Configuration.update_configurations!
  Project.finish_projects!
  Project.send_reminders!
end

desc "Move to deleted state all backers that are in pending a lot of time"
task :move_pending_backers_to_trash => [:environment] do
  Backer.where("state in('pending') and created_at + interval '6 days' < current_timestamp").update_all({state: 'deleted'})
end

desc "Cancel all waiting_confirmation backers that is passed 4 weekdays"
task :cancel_expired_waiting_confirmation_backers => :environment do
  Backer.can_cancel.update_all(state: 'canceled')
end

desc "Send notification about credits 1 month after the project failed"
task send_credits_notification: :environment do
  Backer.send_credits_notification
end

desc "Create first versions for rewards"
task :index_rewards_versions => :environment do
  Reward.all.each do |reward|
    unless reward.versions.count > 0
      puts "update! #{reward.id}"
      reward.update_attributes(reindex_versions: DateTime.now)
    end
  end
end

desc "Update video_embed_url column"
{'fraction_non_alphanumeric': 0.08, 'fraction_numerical': 0.0035164835164835165, 'mean_word_length': 5.540229885057471, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3175316', 'n_tokens_mistral': 685, 'n_tokens_neox': 684, 'n_words': 220}