2016-12-05 13:17:42 +00:00
|
|
|
module Ci
|
2016-12-05 13:22:41 +00:00
|
|
|
# Currently this is artificial object, constructed dynamically
|
|
|
|
# We should migrate this object to actual database record in the future
|
|
|
|
class Stage
|
|
|
|
include StaticModel
|
2016-12-05 13:17:42 +00:00
|
|
|
|
|
|
|
attr_reader :pipeline, :name
|
|
|
|
|
2016-12-05 13:22:41 +00:00
|
|
|
def initialize(pipeline, name: name, status: nil)
|
2016-12-05 13:17:42 +00:00
|
|
|
@pipeline, @name, @status = pipeline, name, status
|
|
|
|
end
|
|
|
|
|
2016-12-05 13:22:41 +00:00
|
|
|
def to_param
|
|
|
|
name
|
|
|
|
end
|
|
|
|
|
2016-12-05 13:17:42 +00:00
|
|
|
def status
|
|
|
|
@status ||= statuses.latest.status
|
|
|
|
end
|
|
|
|
|
|
|
|
def statuses
|
2016-12-05 13:22:41 +00:00
|
|
|
@statuses ||= pipeline.statuses.where(stage: stage)
|
2016-12-05 13:17:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def builds
|
2016-12-05 13:22:41 +00:00
|
|
|
@builds ||= pipeline.builds.where(stage: stage)
|
2016-12-05 13:17:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|