2017-03-22 14:54:49 -04:00
|
|
|
module Ci
|
|
|
|
class ScheduledTrigger < ActiveRecord::Base
|
|
|
|
extend Ci::Model
|
|
|
|
|
|
|
|
acts_as_paranoid
|
|
|
|
|
|
|
|
belongs_to :project
|
|
|
|
belongs_to :owner, class_name: "User"
|
|
|
|
|
|
|
|
def schedule_next_run!
|
|
|
|
next_time = Ci::CronParser.new(cron, cron_time_zone).next_time_from_now
|
2017-03-23 11:18:13 -04:00
|
|
|
if next_time.present?
|
|
|
|
update_attributes(next_run_at: next_time)
|
|
|
|
end
|
2017-03-22 14:54:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def update_last_run!
|
2017-03-23 11:18:13 -04:00
|
|
|
update_attributes(last_run_at: Time.now)
|
2017-03-22 14:54:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|