summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-03-23 03:54:49 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-04-06 23:46:58 +0900
commit5f715f1d32c6f5ce25b3721bde8f476173afadc8 (patch)
treeaae1982a02c2c53c0da9229154e45b6fecb01f61 /app/models
parent46e4ed6bd0c8c256bce6d35b4bb992d77fd09971 (diff)
downloadgitlab-ce-5f715f1d32c6f5ce25b3721bde8f476173afadc8.tar.gz
Add scheduled_trigger model. Add cron parser. Plus, specs.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/scheduled_trigger.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/ci/scheduled_trigger.rb b/app/models/ci/scheduled_trigger.rb
new file mode 100644
index 00000000000..5b1ff7bd7a4
--- /dev/null
+++ b/app/models/ci/scheduled_trigger.rb
@@ -0,0 +1,23 @@
+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
+ update(:next_run_at => next_time) if next_time.present?
+ end
+
+ def valid_ref?
+ true #TODO:
+ end
+
+ def update_last_run!
+ update(:last_run_at => Time.now)
+ end
+ end
+end