Class: Ci::PipelineSchedules::CalculateNextRunService
- Inherits:
-
BaseService
- Object
- BaseService
- Ci::PipelineSchedules::CalculateNextRunService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/ci/pipeline_schedules/calculate_next_run_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#execute(schedule, fallback_method:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/ci/pipeline_schedules/calculate_next_run_service.rb', line 8 def execute(schedule, fallback_method:) @schedule = schedule return fallback_method.call unless plan_cron&.cron_valid? now = Time.zone.now plan_min_run = plan_cron.next_time_from(now) schedule_next_run = schedule_cron.next_time_from(now) return schedule_next_run if worker_cron.match?(schedule_next_run) && plan_min_run <= schedule_next_run plan_next_run = plan_cron.next_time_from(schedule_next_run) return plan_next_run if worker_cron.match?(plan_next_run) worker_next_run = worker_cron.next_time_from(schedule_next_run) return worker_next_run if plan_min_run <= worker_next_run worker_cron.next_time_from(plan_next_run) end |