summaryrefslogtreecommitdiff
path: root/app/models/ci/trigger_schedule.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-04-14 11:01:02 +0200
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-04-19 21:04:54 +0200
commit46386a30dbb0cc2d45df54f86e434f191fb7a790 (patch)
treeb96729bdc0ef9d5c7b9fee1d6d867df6d8a476fe /app/models/ci/trigger_schedule.rb
parentc57e66bebb930b1a7be539a809f7f5a8188e9870 (diff)
downloadgitlab-ce-46386a30dbb0cc2d45df54f86e434f191fb7a790.tar.gz
WIP
Diffstat (limited to 'app/models/ci/trigger_schedule.rb')
-rw-r--r--app/models/ci/trigger_schedule.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/ci/trigger_schedule.rb b/app/models/ci/trigger_schedule.rb
index 012a18eb439..454c73ca9be 100644
--- a/app/models/ci/trigger_schedule.rb
+++ b/app/models/ci/trigger_schedule.rb
@@ -12,19 +12,31 @@ module Ci
validates :cron, unless: :importing_or_inactive?, cron: true, presence: { unless: :importing_or_inactive? }
validates :cron_timezone, cron_timezone: true, presence: { unless: :importing_or_inactive? }
validates :ref, presence: { unless: :importing_or_inactive? }
+ validates :description, presence: true
before_save :set_next_run_at
scope :active, -> { where(active: true) }
+ scope :inactive, -> { where(active: false) }
def importing_or_inactive?
importing? || !active?
end
+ def inactive?
+ !active?
+ end
+
def set_next_run_at
self.next_run_at = Gitlab::Ci::CronParser.new(cron, cron_timezone).next_time_from(Time.now)
end
+ def schedule_first_run!
+ if next_run_at < real_next_run
+ #TODO create a schedule service to be used here and in the worker
+ end
+ end
+
def schedule_next_run!
save! # with set_next_run_at
rescue ActiveRecord::RecordInvalid