Commit 878ca2e6 authored by Yorick Peterse's avatar Yorick Peterse

Exclude coverage data from the pipelines page

When displaying a project's pipelines
(Projects::PipelinesController#index) we now exclude the coverage data.
This data was not used by the frontend, yet getting it would require one
SQL query per pipeline. These queries in turn could be quite expensive
on GitLab.com.
parent 19428e80
...@@ -34,7 +34,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -34,7 +34,7 @@ class Projects::PipelinesController < Projects::ApplicationController
pipelines: PipelineSerializer pipelines: PipelineSerializer
.new(project: @project, current_user: @current_user) .new(project: @project, current_user: @current_user)
.with_pagination(request, response) .with_pagination(request, response)
.represent(@pipelines), .represent(@pipelines, disable_coverage: true),
count: { count: {
all: @pipelines_count, all: @pipelines_count,
running: @running_count, running: @running_count,
......
...@@ -4,7 +4,11 @@ class PipelineEntity < Grape::Entity ...@@ -4,7 +4,11 @@ class PipelineEntity < Grape::Entity
expose :id expose :id
expose :user, using: UserEntity expose :user, using: UserEntity
expose :active?, as: :active expose :active?, as: :active
expose :coverage
# Coverage isn't always necessary (e.g. when displaying project pipelines in
# the UI). Instead of creating an entirely different entity we just allow the
# disabling of this specific field whenever necessary.
expose :coverage, unless: proc { options[:disable_coverage] }
expose :source expose :source
expose :created_at, :updated_at expose :created_at, :updated_at
......
...@@ -41,6 +41,12 @@ describe Projects::PipelinesController do ...@@ -41,6 +41,12 @@ describe Projects::PipelinesController do
expect(json_response['count']['finished']).to eq '1' expect(json_response['count']['finished']).to eq '1'
end end
it 'does not include coverage data for the pipelines' do
subject
expect(json_response['pipelines'][0]).not_to include('coverage')
end
context 'when performing gitaly calls', :request_store do context 'when performing gitaly calls', :request_store do
it 'limits the Gitaly requests' do it 'limits the Gitaly requests' do
expect { subject }.to change { Gitlab::GitalyClient.get_request_count }.by(3) expect { subject }.to change { Gitlab::GitalyClient.get_request_count }.by(3)
......
...@@ -26,6 +26,13 @@ describe PipelineEntity do ...@@ -26,6 +26,13 @@ describe PipelineEntity do
expect(subject).to include :updated_at, :created_at expect(subject).to include :updated_at, :created_at
end end
it 'excludes coverage data when disabled' do
entity = described_class
.represent(pipeline, request: request, disable_coverage: true)
expect(entity.as_json).not_to include(:coverage)
end
it 'contains details' do it 'contains details' do
expect(subject).to include :details expect(subject).to include :details
expect(subject[:details]) expect(subject[:details])
......
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