blob: 2fd369c9afff5529e81cae3bb66148875b3f0080 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# frozen_string_literal: true
module Ci
# Currently this is artificial object, constructed dynamically
# We should migrate this object to actual database record in the future
class LegacyStage
include StaticModel
attr_reader :pipeline, :name
delegate :project, to: :pipeline
def initialize(pipeline, name:, status: nil, warnings: nil)
@pipeline = pipeline
@name = name
@status = status
# support ints and booleans
@has_warnings = ActiveRecord::Type::Boolean.new.cast(warnings)
end
def groups
@groups ||= Ci::Group.fabricate(self)
end
def to_param
name
end
def statuses_count
@statuses_count ||= statuses.count
end
def status
@status ||= statuses.latest.slow_composite_status
end
def detailed_status(current_user)
Gitlab::Ci::Status::Stage::Factory
.new(self, current_user)
.fabricate!
end
def statuses
@statuses ||= pipeline.statuses.where(stage: name)
end
def builds
@builds ||= pipeline.builds.where(stage: name)
end
def success?
status.to_s == 'success'
end
def has_warnings?
# lazilly calculate the warnings
if @has_warnings.nil?
@has_warnings = statuses.latest.failed_but_allowed.any?
end
@has_warnings
end
def manual_playable?
%[manual scheduled skipped].include?(status.to_s)
end
end
end
|