diff options
-rw-r--r-- | app/controllers/projects/pipeline_schedules_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/projects/services_controller.rb | 2 | ||||
-rw-r--r-- | app/models/ci/trigger_schedule.rb | 12 | ||||
-rw-r--r-- | db/schema.rb | 18 |
4 files changed, 30 insertions, 3 deletions
diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index fd03eab7340..ae95185d2ba 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -47,6 +47,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController end def destroy + @pipeline_schedule.destroy end private diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index f9d798d0455..e420e140d2b 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -13,6 +13,8 @@ class Projects::ServicesController < Projects::ApplicationController end def update + byebug + @service.assign_attributes(service_params[:service]) if @service.save(context: :manual_change) redirect_to( diff --git a/app/models/ci/trigger_schedule.rb b/app/models/ci/trigger_schedule.rb index 454c73ca9be..ec7dec8ca59 100644 --- a/app/models/ci/trigger_schedule.rb +++ b/app/models/ci/trigger_schedule.rb @@ -15,12 +15,13 @@ module Ci validates :description, presence: true before_save :set_next_run_at + after_create :schedule_first_run! scope :active, -> { where(active: true) } - scope :inactive, -> { where(active: false) } + scope :inactive, -> { where.not(active: true) } # cover for active = nil def importing_or_inactive? - importing? || !active? + importing? || inactive? end def inactive? @@ -33,6 +34,7 @@ module Ci def schedule_first_run! if next_run_at < real_next_run + Project::SchedulePipelineService.new(self).execute #TODO create a schedule service to be used here and in the worker end end @@ -49,5 +51,11 @@ module Ci Gitlab::Ci::CronParser.new(worker_cron, worker_time_zone) .next_time_from(next_run_at) end + + def self.next_schedular_run + Gitlab::Ci::CronParser.new(Settings.cron_jobs['trigger_schedule_worker']['cron'], + Time.zone.name). + next_time_from(Time.now) + end end end diff --git a/db/schema.rb b/db/schema.rb index d46b7564958..764eff0d796 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -238,6 +238,22 @@ ActiveRecord::Schema.define(version: 20170418103908) do add_index "ci_builds", ["status"], name: "index_ci_builds_on_status", using: :btree add_index "ci_builds", ["token"], name: "index_ci_builds_on_token", unique: true, using: :btree + create_table "ci_pipeline_schedules", force: :cascade do |t| + t.integer "project_id" + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.string "cron" + t.string "cron_timezone" + t.datetime "next_run_at" + t.string "ref" + t.boolean "active" + end + + add_index "ci_pipeline_schedules", ["active", "next_run_at"], name: "index_ci_pipeline_schedules_on_active_and_next_run_at", using: :btree + add_index "ci_pipeline_schedules", ["next_run_at"], name: "index_ci_pipeline_schedules_on_next_run_at", using: :btree + add_index "ci_pipeline_schedules", ["project_id"], name: "index_ci_pipeline_schedules_on_project_id", using: :btree + create_table "ci_pipelines", force: :cascade do |t| t.string "ref" t.string "sha" @@ -1303,10 +1319,10 @@ ActiveRecord::Schema.define(version: 20170418103908) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" - t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false + t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree |