Created
February 17, 2016 14:45
-
-
Save zemagno/fcd470b2fee9b5fd13dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :scheduler do | |
desc "Scheduler..." | |
task :go => :environment do | |
Scheduler.go | |
puts "Scheduler.go - #{Time.now} - Success!" | |
end | |
end | |
class Scheduler < ActiveRecord::Base | |
attr_accessible :job, :when, :ordem | |
default_scope order('ordem ASC') | |
def self.go | |
hoje = Time.now() | |
Scheduler.all.each do |x| | |
if (((x.when.include? "[#{hoje.day}]") || (x.when.include? ["[dom]","[seg]","[ter]","[qua]","[qui]","[sex]","[sab]"][hoje.wday])) and x.when.include? "[H#{hoje.hour}]") | |
puts x.job | |
Producao.dispatcherJob(x.job) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment