Merge branch 'sh-cache-pipeline-find-commits' into 'master'

Cache FindCommit results in pipelines view

See merge request gitlab-org/gitlab-ce!26776
This commit is contained in:
Kamil Trzciński 2019-04-02 14:29:49 +00:00
commit 723f936fb1
3 changed files with 17 additions and 4 deletions

View File

@ -31,10 +31,7 @@ class Projects::PipelinesController < Projects::ApplicationController
Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL)
render json: {
pipelines: PipelineSerializer
.new(project: @project, current_user: @current_user)
.with_pagination(request, response)
.represent(@pipelines, disable_coverage: true, preload: true),
pipelines: serialize_pipelines,
count: {
all: @pipelines_count,
running: @running_count,
@ -150,6 +147,15 @@ class Projects::PipelinesController < Projects::ApplicationController
private
def serialize_pipelines
::Gitlab::GitalyClient.allow_ref_name_caching do
PipelineSerializer
.new(project: @project, current_user: @current_user)
.with_pagination(request, response)
.represent(@pipelines, disable_coverage: true, preload: true)
end
end
def render_show
respond_to do |format|
format.html do

View File

@ -0,0 +1,5 @@
---
title: Cache FindCommit results in pipelines view
merge_request: 26776
author:
type: performance

View File

@ -28,6 +28,8 @@ describe Projects::PipelinesController do
end
it 'returns serialized pipelines', :request_store do
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
queries = ActiveRecord::QueryRecorder.new do
get_pipelines_index_json
end