diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-23 10:24:57 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-23 10:31:21 +0200 |
commit | fd871802b5e7085f98f8d836ecd4b22e8d230f2f (patch) | |
tree | 2fcbaa0bf16972192fcf40f9e2ac6d7d5db10245 | |
parent | ad47f2094bf61867d2b5e4c24540c7c5b8a6358d (diff) | |
download | gitlab-ce-zj-pipeline-show-realtime-job-list.tar.gz |
Update entities for real time pipeline job listzj-pipeline-show-realtime-job-list
Now exposed on the pipeline:
- queued_duration
On the BuildEntity:
- tags
- timestamps regarding starting, finishing, and queueing
- Artifacts
-rw-r--r-- | app/models/ci/stage.rb | 2 | ||||
-rw-r--r-- | app/serializers/build_entity.rb | 9 | ||||
-rw-r--r-- | app/serializers/pipeline_entity.rb | 1 | ||||
-rw-r--r-- | spec/serializers/build_entity_spec.rb | 10 | ||||
-rw-r--r-- | spec/serializers/pipeline_entity_spec.rb | 4 |
5 files changed, 17 insertions, 9 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 9bda3186c30..d9adb73e563 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -16,7 +16,7 @@ module Ci end def groups - @groups ||= statuses.ordered.latest + @groups ||= statuses.ordered.latest.preload(:tags) .sort_by(&:sortable_name).group_by(&:group_name) .map do |group_name, grouped_statuses| Ci::Group.new(self, name: group_name, jobs: grouped_statuses) diff --git a/app/serializers/build_entity.rb b/app/serializers/build_entity.rb index e2276808b90..570ac9d7a3e 100644 --- a/app/serializers/build_entity.rb +++ b/app/serializers/build_entity.rb @@ -1,8 +1,9 @@ class BuildEntity < Grape::Entity include RequestAwareEntity - expose :id - expose :name + expose :id, :name + expose :created_at, :updated_at + expose :queued_at, :started_at, :finished_at expose :build_path do |build| path_to(:namespace_project_build, build) @@ -17,9 +18,9 @@ class BuildEntity < Grape::Entity end expose :playable?, as: :playable - expose :created_at - expose :updated_at expose :detailed_status, as: :status, with: StatusEntity + expose :tag_list, as: :tags + expose :artifacts, using: BuildArtifactEntity private diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb index ea57cc97a7e..4ebe9cb6aca 100644 --- a/app/serializers/pipeline_entity.rb +++ b/app/serializers/pipeline_entity.rb @@ -5,6 +5,7 @@ class PipelineEntity < Grape::Entity expose :user, using: UserEntity expose :active?, as: :active expose :coverage + expose :queued_duration expose :path do |pipeline| namespace_project_pipeline_path( diff --git a/spec/serializers/build_entity_spec.rb b/spec/serializers/build_entity_spec.rb index b5eb84ae43b..a674835da5c 100644 --- a/spec/serializers/build_entity_spec.rb +++ b/spec/serializers/build_entity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe BuildEntity do let(:user) { create(:user) } - let(:build) { create(:ci_build) } + let(:build) { create(:ci_build, :tags) } let(:request) { double('request') } before do @@ -29,7 +29,7 @@ describe BuildEntity do end it 'contains timestamps' do - expect(subject).to include(:created_at, :updated_at) + expect(subject).to include(:created_at, :updated_at, :queued_at, :started_at, :finished_at) end it 'contains details' do @@ -37,6 +37,12 @@ describe BuildEntity do expect(subject[:status]).to include :icon, :favicon, :text, :label end + it 'exposes the tags list' do + expect(subject).to include :tags + expect(subject[:tags]).not_to be_empty + expect(subject[:tags]).to include('docker', 'ruby') + end + context 'when build is a regular job' do it 'does not contain path to play action' do expect(subject).not_to include(:play_path) diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb index d2482ac434b..8af74387069 100644 --- a/spec/serializers/pipeline_entity_spec.rb +++ b/spec/serializers/pipeline_entity_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe PipelineEntity do - let(:user) { create(:user) } + set(:user) { create(:user) } let(:request) { double('request') } before do @@ -20,7 +20,7 @@ describe PipelineEntity do it 'contains required fields' do expect(subject).to include :id, :user, :path, :coverage - expect(subject).to include :ref, :commit + expect(subject).to include :ref, :commit, :queued_duration expect(subject).to include :updated_at, :created_at end |