Class: CommitStatus

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Statuseable
Defined in:
app/models/commit_status.rb

Overview

Schema Information

Table name: ci_builds

id                 :integer          not null, primary key
project_id         :integer
status             :string
finished_at        :datetime
trace              :text
created_at         :datetime
updated_at         :datetime
started_at         :datetime
runner_id          :integer
coverage           :float
commit_id          :integer
commands           :text
job_id             :integer
name               :string
deploy             :boolean          default(FALSE)
options            :text
allow_failure      :boolean          default(FALSE), not null
stage              :string
trigger_request_id :integer
stage_idx          :integer
tag                :boolean
ref                :string
user_id            :integer
type               :string
target_url         :string
description        :string
artifacts_file     :text
gl_project_id      :integer
artifacts_metadata :text
erased_by_id       :integer
erased_at          :datetime

Direct Known Subclasses

Ci::Build, GenericCommitStatus

Constant Summary

Constants included from Statuseable

Statuseable::AVAILABLE_STATUSES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Statuseable

#active?, #complete?, #started?

Class Method Details

.stagesObject


93
94
95
96
# File 'app/models/commit_status.rb', line 93

def self.stages
  order_by = 'max(stage_idx)'
  group('stage').order(order_by).pluck(:stage, order_by).map(&:first).compact
end

.stages_statusObject


98
99
100
101
102
103
# File 'app/models/commit_status.rb', line 98

def self.stages_status
  all.stages.inject({}) do |h, stage|
    h[stage] = all.where(stage: stage).status
    h
  end
end

Instance Method Details

#before_shaObject


89
90
91
# File 'app/models/commit_status.rb', line 89

def before_sha
  commit.before_sha || Gitlab::Git::BLANK_SHA
end

#durationObject


109
110
111
112
113
114
115
116
117
# File 'app/models/commit_status.rb', line 109

def duration
  duration =
    if started_at && finished_at
      finished_at - started_at
    elsif started_at
      Time.now - started_at
    end
  duration
end

#ignored?Boolean

Returns:

  • (Boolean)

105
106
107
# File 'app/models/commit_status.rb', line 105

def ignored?
  allow_failure? && (failed? || canceled?)
end

#stuck?Boolean

Returns:

  • (Boolean)

119
120
121
# File 'app/models/commit_status.rb', line 119

def stuck?
  false
end