Commit 2f972ad4 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Preserve stage values and use StaticModel

parent d865aeda
module Ci
class Stage < ActiveRecord::Base
include ActiveModel::Model
# Currently this is artificial object, constructed dynamically
# We should migrate this object to actual database record in the future
class Stage
include StaticModel
attr_reader :pipeline, :name
def initialize(pipeline, name: name, status: status = nil)
def initialize(pipeline, name: name, status: nil)
@pipeline, @name, @status = pipeline, name, status
end
def to_param
name
end
def status
@status ||= statuses.latest.status
end
def statuses
pipeline.statuses.where(stage: stage)
@statuses ||= pipeline.statuses.where(stage: stage)
end
def builds
pipeline.builds.where(stage: stage)
@builds ||= pipeline.builds.where(stage: stage)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment