diff options
author | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2017-05-06 16:45:46 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2017-05-06 16:45:46 +0000 |
commit | c17e6a6c68b0412b3433632802b852db474a7b30 (patch) | |
tree | a7e6b1ec2e0e5f691aa6fd7585f5b63a15131114 /app/models/ci/group.rb | |
parent | 1186dcabbfb8e885351c1ef05d4583fd474732e9 (diff) | |
download | gitlab-ce-c17e6a6c68b0412b3433632802b852db474a7b30.tar.gz |
Real time pipeline show action
Diffstat (limited to 'app/models/ci/group.rb')
-rw-r--r-- | app/models/ci/group.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/app/models/ci/group.rb b/app/models/ci/group.rb new file mode 100644 index 00000000000..87898b086c6 --- /dev/null +++ b/app/models/ci/group.rb @@ -0,0 +1,40 @@ +module Ci + ## + # This domain model is a representation of a group of jobs that are related + # to each other, like `rspec 0 1`, `rspec 0 2`. + # + # It is not persisted in the database. + # + class Group + include StaticModel + + attr_reader :stage, :name, :jobs + + delegate :size, to: :jobs + + def initialize(stage, name:, jobs:) + @stage = stage + @name = name + @jobs = jobs + end + + def status + @status ||= commit_statuses.status + end + + def detailed_status(current_user) + if jobs.one? + jobs.first.detailed_status(current_user) + else + Gitlab::Ci::Status::Group::Factory + .new(self, current_user).fabricate! + end + end + + private + + def commit_statuses + @commit_statuses ||= CommitStatus.where(id: jobs.map(&:id)) + end + end +end |