Class: Ci::PipelineSchedule

Inherits:
ApplicationRecord show all
Extended by:
Gitlab::Utils::Override
Includes:
CronSchedulable, EachBatch, Importable, Limitable, StripAttribute
Defined in:
app/models/ci/pipeline_schedule.rb

Constant Summary

Constants included from Limitable

Limitable::GLOBAL_SCOPE

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Instance Method Summary collapse

Methods included from Gitlab::Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods included from Schedulable

#schedule_next_run!

Methods included from StripAttribute

#strip_attributes!

Methods inherited from ApplicationRecord

model_name, table_name_prefix

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Method Details

#daily_limitObject


65
66
67
# File 'app/models/ci/pipeline_schedule.rb', line 65

def daily_limit
  project.actual_limits.limit_for(:ci_daily_pipeline_schedule_triggers)
end

#deactivate!Object


50
51
52
# File 'app/models/ci/pipeline_schedule.rb', line 50

def deactivate!
  update_attribute(:active, false)
end

#for_tag?Boolean

Returns:

  • (Boolean)

75
76
77
78
79
# File 'app/models/ci/pipeline_schedule.rb', line 75

def for_tag?
  return false unless ref.present?

  ref.start_with? 'refs/tags/'
end

#inactive?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'app/models/ci/pipeline_schedule.rb', line 46

def inactive?
  !active?
end

#job_variablesObject


54
55
56
# File 'app/models/ci/pipeline_schedule.rb', line 54

def job_variables
  variables&.map(&:to_runner_variable) || []
end

#own!(user) ⇒ Object


42
43
44
# File 'app/models/ci/pipeline_schedule.rb', line 42

def own!(user)
  update(owner: user)
end

#owned_by?(current_user) ⇒ Boolean

Returns:

  • (Boolean)

38
39
40
# File 'app/models/ci/pipeline_schedule.rb', line 38

def owned_by?(current_user)
  owner == current_user
end

#ref_for_displayObject


69
70
71
72
73
# File 'app/models/ci/pipeline_schedule.rb', line 69

def ref_for_display
  return unless ref.present?

  ref.gsub(%r{^refs/(heads|tags)/}, '')
end

#set_next_run_atObject


59
60
61
62
63
# File 'app/models/ci/pipeline_schedule.rb', line 59

def set_next_run_at
  self.next_run_at = ::Ci::PipelineSchedules::CalculateNextRunService # rubocop: disable CodeReuse/ServiceClass
                       .new(project)
                       .execute(self, fallback_method: method(:calculate_next_run_at))
end