Commit 6280fd37 authored by Paco Guzman's avatar Paco Guzman

Reduce number of database queries on builds tab

parent 7bbb523b
......@@ -12,6 +12,7 @@ v 8.12.0 (unreleased)
v 8.11.2 (unreleased)
- 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)
- Does not halt the GitHub import process when an error occurs
......
......@@ -352,7 +352,7 @@ module Ci
end
def artifacts?
!artifacts_expired? && artifacts_file.exists?
!artifacts_expired? && self[:artifacts_file].present?
end
def artifacts_metadata?
......
......@@ -83,7 +83,7 @@ module Ci
end
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
def project_id
......
......@@ -25,6 +25,8 @@ class CommitStatus < ActiveRecord::Base
scope :retried, -> { where.not(id: latest) }
scope :ordered, -> { order(:name) }
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
event :enqueue do
......
......@@ -8,8 +8,8 @@
- if stage
&nbsp;
= stage.titleize
= render statuses.latest.ordered, 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.latest_ci_stages, coverage: @project.build_coverage_enabled?, stage: false, ref: false, allow_retry: true
= render statuses.retried_ci_stages, coverage: @project.build_coverage_enabled?, stage: false, ref: false, retried: true
%tr
%td{colspan: 10}
&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