summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-04-02 14:29:49 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2019-04-02 14:29:49 +0000
commit723f936fb1805ccd4c0d03f6f8599dbc4a2f5570 (patch)
treebebe2756a26d47e4fbf7ab232289662fe0baecd7
parent8b9da458ec31d053da0a26cf7b23ecf2f8baa8a6 (diff)
parente37383d45395c0c7cefc1dda3be12bd4c2d6cc4f (diff)
downloadgitlab-ce-723f936fb1805ccd4c0d03f6f8599dbc4a2f5570.tar.gz
Merge branch 'sh-cache-pipeline-find-commits' into 'master'
Cache FindCommit results in pipelines view See merge request gitlab-org/gitlab-ce!26776
-rw-r--r--app/controllers/projects/pipelines_controller.rb14
-rw-r--r--changelogs/unreleased/sh-cache-pipeline-find-commits.yml5
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb2
3 files changed, 17 insertions, 4 deletions
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index 6a86f8ca729..c306ba3ffcf 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -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
diff --git a/changelogs/unreleased/sh-cache-pipeline-find-commits.yml b/changelogs/unreleased/sh-cache-pipeline-find-commits.yml
new file mode 100644
index 00000000000..2acf180d6fa
--- /dev/null
+++ b/changelogs/unreleased/sh-cache-pipeline-find-commits.yml
@@ -0,0 +1,5 @@
+---
+title: Cache FindCommit results in pipelines view
+merge_request: 26776
+author:
+type: performance
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index ece8532cb84..b64ae552efc 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -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