Commit f6be8c04 authored by Shinya Maeda's avatar Shinya Maeda

Remove less_than_1_hour_from_now comments. Dry up def schedule_next_run!

parent a67aff6d
......@@ -14,32 +14,12 @@ module Ci
validates :cron, cron: true, presence: { unless: :importing? }
validates :cron_time_zone, presence: { unless: :importing? }
validates :ref, presence: { unless: :importing? }
# validate :check_cron_frequency
after_create :schedule_next_run!
def schedule_next_run!
next_time = Ci::CronParser.new(cron, cron_time_zone).next_time_from(Time.now)
# if next_time.present? && !less_than_1_hour_from_now?(next_time)
if next_time.present?
update!(next_run_at: next_time)
end
update!(next_run_at: next_time) if next_time.present?
end
# private
# def less_than_1_hour_from_now?(time)
# puts "diff: #{(time - Time.now).abs.inspect}"
# ((time - Time.now).abs < 1.hour) ? true : false
# end
# def check_cron_frequency
# next_time = Ci::CronParser.new(cron, cron_time_zone).next_time_from(Time.now)
# if less_than_1_hour_from_now?(next_time)
# self.errors.add(:cron, " can not be less than 1 hour")
# end
# end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment