From f6be8c048555f2d1086e7beed336b6187edb4d58 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 4 Apr 2017 16:58:02 +0900 Subject: [PATCH] Remove less_than_1_hour_from_now comments. Dry up def schedule_next_run! --- app/models/ci/trigger_schedule.rb | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/app/models/ci/trigger_schedule.rb b/app/models/ci/trigger_schedule.rb index 58337b34d80..6e7c0b4f6c2 100644 --- a/app/models/ci/trigger_schedule.rb +++ b/app/models/ci/trigger_schedule.rb @@ -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