diff options
author | Stan Hu <stanhu@gmail.com> | 2019-03-29 19:23:51 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-04-02 14:15:32 +0300 |
commit | e37383d45395c0c7cefc1dda3be12bd4c2d6cc4f (patch) | |
tree | fe2a6d2890e1f09d110f5e7241b7f3ddbb568b4d /app/controllers/projects/pipelines_controller.rb | |
parent | ee89d9550b6f0f5a04098564c96283121dee8f41 (diff) |
Cache FindCommit results in pipelines view
For each pipeline, the controller will call `Pipeline#latest?` to
determine if the pipeline's ref is the latest for that branch.
Since it's likely that the same branches are being used in each
pipeline, we can reduce Gitaly overhead by caching the results
of the FindCommit call.
Diffstat (limited to 'app/controllers/projects/pipelines_controller.rb')
-rw-r--r-- | app/controllers/projects/pipelines_controller.rb | 14 |
1 files changed, 10 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 |