Compute all pipelines count from other statuses
Each request to the pipelines index is executing 5 SQL count queries.
One for the pagination and four of them are for computing the data for the statuses tab:
@running_count = limited_pipelines_count(project, 'running')
@pending_count = limited_pipelines_count(project, 'pending')
@finished_count = limited_pipelines_count(project, 'finished')
@pipelines_count = limited_pipelines_count(project)
I think that we can compute the @pipelines_count
number as a sum of the previous counts:
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index cf1555da8b3..4eb942efd0f 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -34,7 +34,8 @@ class Projects::PipelinesController < Projects::ApplicationController
@running_count = limited_pipelines_count(project, 'running')
@pending_count = limited_pipelines_count(project, 'pending')
@finished_count = limited_pipelines_count(project, 'finished')
- @pipelines_count = limited_pipelines_count(project)
+ @pipelines_count = [@running_count, @pending_count, @finished_count].map(&:to_i).sum
+ @pipelines_count = '1000+' if @pipelines_count > 1000
respond_to do |format|
format.html
- The available list of statues contains a few extra ones but a pipeline doesn't spend a lot of time in them. When the finished count reaches 1000+ records, the all count is guaranteed to be more than 1000 records.
If we still want status accuracy, we can do:
@pipelines_count = [@running_count, @pending_count, @finished_count].map(&:to_i).sum
@pipelines_count = if @pipelines_count > 1000
'1000+'
else
limited_pipelines_count(project)
end
But the best solution is to remove the tab completely: #219276 (closed)