<commit_before>#!/usr/bin/env ruby

#You might want to change this
ENV["RAILS_ENV"] ||= "development"

require File.dirname(__FILE__) + "/../../config/environment"

$running = true;
Signal.trap("TERM") do
  $running = false
end

while($running) do

  date = Time.now.utc.change(:min => 0) + 16.hours

  puts "Checking tasks between #{date} and #{date + 1.hours}"

  tasks = Task.find(:all, :conditions => ["due_at > ? AND due_at < ? AND completed_at IS NULL", date, date + 1.hours], :order => "company_id")

  if tasks.size > 0
    puts "Got reminders to send.. #{tasks.size} tasks."

    user_ids = []
    tasks.each do |t|
      if t.users.size > 0
        user_ids += t.users.collect { |u| u.id if u.receive_notifications.to_i > 0 }
      end
    end
    user_ids = user_ids.compact.uniq
    puts "Users involved: " + user_ids.size.to_s

    user_ids.each do |u|
      user = User.find(u)
      puts "Handling tasks for #{user.name} / #{user.company.name}"
      user_tasks = user.tasks.find(:all, :conditions => ["due_at > ? AND due_at < ? AND completed_at IS NULL", date, date + 1.hours], :order => 'project_id, name')

      user_tasks.each do | ut |
        puts "  [#{ut.id}] ##{ut.task_num} #{ut.name}"
      end

      begin
      	Notifications::deliver_reminder(user_tasks, user)
      rescue
        puts "  [#{ut.id}] #{user.email} failed."
      end

    end
  end

  secs = ((Time.now.change(:min => 1) + 1.hour) - Time.now).to_i
  puts "Done... Sleeping for #{secs}s"

  sleep secs
end

<commit_msg>[ClockingIT @ Don't break on exception]<commit_after>#!/usr/bin/env ruby

#You might want to change this
ENV["RAILS_ENV"] ||= "development"

require File.dirname(__FILE__) + "/../../config/environment"

$running = true;
Signal.trap("TERM") do
  $running = false
end

while($running) do

  date = Time.now.utc.change(:min => 0) + 16.hours

  puts "Checking tasks between #{date} and #{date + 1.hours}"

  tasks = Task.find(:all, :conditions => ["due_at > ? AND due_at < ? AND completed_at IS NULL", date, date + 1.hours], :order => "company_id")

  if tasks.size > 0
    puts "Got reminders to send.. #{tasks.size} tasks."

    user_ids = []
    tasks.each do |t|
      if t.users.size > 0
        user_ids += t.users.collect { |u| u.id if u.receive_notifications.to_i > 0 }
      end
    end
    user_ids = user_ids.compact.uniq
    puts "Users involved: " + user_ids.size.to_s

    user_ids.each do |u|
      user = User.find(u)
      puts "Handling tasks for #{user.name} / #{user.company.name}"
      user_tasks = user.tasks.find(:all, :conditions => ["due_at > ? AND due_at < ? AND completed_at IS NULL", date, date + 1.hours], :order => 'project_id, name')

      user_tasks.each do |ut|
        puts "  [#{ut.id}] ##{ut.task_num} #{ut.name}"
      end

      begin
        Notifications::deliver_reminder(user_tasks, user)
      rescue
        puts "  [#{user.id}] #{user.email} failed."
      end

    end
  end

  secs = ((Time.now.change(:min => 1) + 1.hour) - Time.now).to_i
  puts "Done... Sleeping for #{secs}s"

  sleep secs
end


{'fraction_non_alphanumeric': 0.16149068322981366, 'fraction_numerical': 0.007191892775416803, 'mean_word_length': 2.745410036719706, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '328122', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1096, 'n_words': 284}