Method: Mutx::Workers::MutxCron#validate_and_execute

Defined in:
lib/mutx/background_jobs/workers/mutx_cron.rb

#validate_and_execute(task) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/mutx/background_jobs/workers/mutx_cron.rb', line 148

def validate_and_execute task

@days.detect{|day| @none_day = "task_with_day" if task[:"#{day}"]}

# If no day execution is seted, works as always
if (((!task[:cron_time].eql? "") && (!task[:cron_time].eql? "0")) && (((Time.now.utc - @@last_exec_time.utc) + 1) >= (task[:cron_time].to_i * 60)) && (@none_day.eql? true))
  execute task
# If there is a day seted, and that day is today, and no execution time is seted
elsif (((!task[:cron_time].eql? "") && (!task[:cron_time].eql? "0")) && (((Time.now.utc - @@last_exec_time.utc) + 1) >= (task[:cron_time].to_i * 60)) && (@none_day.eql? "task_with_day") && (task[:"#{@today}"].eql? "on") && (task[:start_time].empty?) && (task[:stop_time].empty?))
  execute task
# If there is a day seted, and that day is today, and execution range time is seted
elsif (((!task[:cron_time].eql? "") && (!task[:cron_time].eql? "0")) && (((Time.now.utc - @@last_exec_time.utc) + 1) >= (task[:cron_time].to_i * 60)) && (@none_day.eql? "task_with_day") && (task[:"#{@today}"].eql? "on") && (!task[:start_time].nil?) && (!task[:stop_time].nil?) )
  if task[:start_time] > task[:stop_time] #initial time is greater than stop time
    check_range_time task
  elsif (@@now_time.between? task[:start_time], task[:stop_time]) #stop time is greater than initial time
    execute task
  else
    puts "Out of date range for: #{task[:name]}"
  end
end#if

end