diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-03-29 14:49:47 +0300 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-04-06 17:46:58 +0300 |
commit | c426763c42d41c9c0c9a9cfe544f3185eeaa984f (patch) | |
tree | e930de34c126d3780e70dcf1bfc4a4d23cbfd6ef /app | |
parent | e32c1a5c92a80c350bbf3b70552be5cf29501fe7 (diff) |
Rename ScheduledTrigger to TriggerSchedule. Because table structure changed.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/trigger.rb | 1 | ||||
-rw-r--r-- | app/models/ci/trigger_schedule.rb (renamed from app/models/ci/scheduled_trigger.rb) | 10 | ||||
-rw-r--r-- | app/workers/trigger_schedule_worker.rb (renamed from app/workers/scheduled_trigger_worker.rb) | 5 |
3 files changed, 8 insertions, 8 deletions
diff --git a/app/models/ci/trigger.rb b/app/models/ci/trigger.rb index cba1d81a861..0a89f3e0640 100644 --- a/app/models/ci/trigger.rb +++ b/app/models/ci/trigger.rb @@ -8,6 +8,7 @@ module Ci belongs_to :owner, class_name: "User" has_many :trigger_requests, dependent: :destroy + has_one :trigger_schedule, dependent: :destroy validates :token, presence: true, uniqueness: true diff --git a/app/models/ci/scheduled_trigger.rb b/app/models/ci/trigger_schedule.rb index 9af274243a5..7efaa228a93 100644 --- a/app/models/ci/scheduled_trigger.rb +++ b/app/models/ci/trigger_schedule.rb @@ -1,11 +1,11 @@ module Ci - class ScheduledTrigger < ActiveRecord::Base + class TriggerSchedule < ActiveRecord::Base extend Ci::Model acts_as_paranoid belongs_to :project - belongs_to :owner, class_name: "User" + belongs_to :trigger def schedule_next_run! next_time = Ci::CronParser.new(cron, cron_time_zone).next_time_from_now @@ -14,8 +14,8 @@ module Ci end end - def update_last_run! - update_attributes(last_run_at: Time.now) - end + # def update_last_run! + # update_attributes(last_run_at: Time.now) + # end end end diff --git a/app/workers/scheduled_trigger_worker.rb b/app/workers/trigger_schedule_worker.rb index 5c2f03dee79..d55e9378e02 100644 --- a/app/workers/scheduled_trigger_worker.rb +++ b/app/workers/trigger_schedule_worker.rb @@ -1,9 +1,9 @@ -class ScheduledTriggerWorker +class TriggerScheduleWorker include Sidekiq::Worker include CronjobQueue def perform - Ci::ScheduledTrigger.where("next_run_at < ?", Time.now).find_each do |trigger| + Ci::TriggerSchedule.where("next_run_at < ?", Time.now).find_each do |trigger| begin Ci::CreatePipelineService.new(trigger.project, trigger.owner, ref: trigger.ref). execute(ignore_skip_ci: true, scheduled_trigger: true) @@ -11,7 +11,6 @@ class ScheduledTriggerWorker Rails.logger.error "#{trigger.id}: Failed to trigger job: #{e.message}" ensure trigger.schedule_next_run! - trigger.update_last_run! end end end |