2017-03-22 18:54:49 +00:00
|
|
|
module Ci
|
2017-03-29 11:49:47 +00:00
|
|
|
class TriggerSchedule < ActiveRecord::Base
|
2017-03-22 18:54:49 +00:00
|
|
|
extend Ci::Model
|
|
|
|
|
|
|
|
acts_as_paranoid
|
|
|
|
|
|
|
|
belongs_to :project
|
2017-03-29 11:49:47 +00:00
|
|
|
belongs_to :trigger
|
2017-03-22 18:54:49 +00:00
|
|
|
|
|
|
|
def schedule_next_run!
|
|
|
|
next_time = Ci::CronParser.new(cron, cron_time_zone).next_time_from_now
|
2017-03-23 15:18:13 +00:00
|
|
|
if next_time.present?
|
|
|
|
update_attributes(next_run_at: next_time)
|
|
|
|
end
|
2017-03-22 18:54:49 +00:00
|
|
|
end
|
|
|
|
|
2017-03-29 11:49:47 +00:00
|
|
|
# def update_last_run!
|
|
|
|
# update_attributes(last_run_at: Time.now)
|
|
|
|
# end
|
2017-03-22 18:54:49 +00:00
|
|
|
end
|
|
|
|
end
|