<commit_before>desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
  include PagesHelper
    unactive_user_ids = User.unactive.collect(&:id)
    @persons = Person.notification_cantidate.include_users(unactive_user_ids)
    @persons.each do |p| 
      @recent_activity_logs = ActivityLog.include_person(p).unread.email_not_sent
      unless @recent_activity_logs.nil?
				begin
		      UserMailer.notify_with_recent_activity(@recent_activity_logs, '<EMAIL>', p.user).deliver
		      email_notification = EmailNotification.create!(:person_id => p.id, :email => p.email)
		      @recent_activity_logs.each { |a| a.log_notification_email!(email_notification) }
          p.increase_email_notification_count!
          p.log_email_notification_time!
		    rescue Exception => e
		      puts "Email sending failed"
		    end
			end
		end
end<commit_msg>Moved cron job to model so it can be easier tested<commit_after>desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
  include PagesHelper
  Cron.recent_activity
end
{'fraction_non_alphanumeric': 0.08574091332712022, 'fraction_numerical': 0.0, 'mean_word_length': 3.9722222222222223, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, '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': '7087594', 'n_tokens_mistral': 358, 'n_tokens_neox': 329, 'n_words': 79}