Commit 9ffa52e9 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch '13912-reduce-pipeline-db-queries' into 'master'

Reduce number of database queries on builds tab

See merge request !5957
parents 306d0661 6280fd37
...@@ -12,6 +12,7 @@ v 8.12.0 (unreleased) ...@@ -12,6 +12,7 @@ v 8.12.0 (unreleased)
v 8.11.2 (unreleased) v 8.11.2 (unreleased)
- Show "Create Merge Request" widget for push events to fork projects on the source project - Show "Create Merge Request" widget for push events to fork projects on the source project
- Reduce number of database queries on builds tab
v 8.11.1 (unreleased) v 8.11.1 (unreleased)
- Does not halt the GitHub import process when an error occurs - Does not halt the GitHub import process when an error occurs
......
...@@ -352,7 +352,7 @@ module Ci ...@@ -352,7 +352,7 @@ module Ci
end end
def artifacts? def artifacts?
!artifacts_expired? && artifacts_file.exists? !artifacts_expired? && self[:artifacts_file].present?
end end
def artifacts_metadata? def artifacts_metadata?
......
...@@ -83,7 +83,7 @@ module Ci ...@@ -83,7 +83,7 @@ module Ci
end end
def stages_with_latest_statuses def stages_with_latest_statuses
statuses.latest.order(:stage_idx).group_by(&:stage) statuses.latest.includes(project: :namespace).order(:stage_idx).group_by(&:stage)
end end
def project_id def project_id
......
...@@ -25,6 +25,8 @@ class CommitStatus < ActiveRecord::Base ...@@ -25,6 +25,8 @@ class CommitStatus < ActiveRecord::Base
scope :retried, -> { where.not(id: latest) } scope :retried, -> { where.not(id: latest) }
scope :ordered, -> { order(:name) } scope :ordered, -> { order(:name) }
scope :ignored, -> { where(allow_failure: true, status: [:failed, :canceled]) } scope :ignored, -> { where(allow_failure: true, status: [:failed, :canceled]) }
scope :latest_ci_stages, -> { latest.ordered.includes(project: :namespace) }
scope :retried_ci_stages, -> { retried.ordered.includes(project: :namespace) }
state_machine :status do state_machine :status do
event :enqueue do event :enqueue do
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
- if stage - if stage
&nbsp; &nbsp;
= stage.titleize = stage.titleize
= render statuses.latest.ordered, coverage: @project.build_coverage_enabled?, stage: false, ref: false, allow_retry: true = render statuses.latest_ci_stages, coverage: @project.build_coverage_enabled?, stage: false, ref: false, allow_retry: true
= render statuses.retried.ordered, coverage: @project.build_coverage_enabled?, stage: false, ref: false, retried: true = render statuses.retried_ci_stages, coverage: @project.build_coverage_enabled?, stage: false, ref: false, retried: true
%tr %tr
%td{colspan: 10} %td{colspan: 10}
&nbsp; &nbsp;
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