Commit 6301bd24 authored by Matija Čupić's avatar Matija Čupić

Preload tags when loading commit statuses

parent 4c7be6fe
...@@ -5,6 +5,7 @@ module Ci ...@@ -5,6 +5,7 @@ module Ci
# We should migrate this object to actual database record in the future # We should migrate this object to actual database record in the future
class LegacyStage class LegacyStage
include StaticModel include StaticModel
include Presentable
attr_reader :pipeline, :name attr_reader :pipeline, :name
......
# frozen_string_literal: true
module Ci
class LegacyStagePresenter < Gitlab::View::Presenter::Delegated
presents :legacy_stage
def preloaded_statuses
legacy_stage.statuses.tap do |statuses|
# rubocop: disable CodeReuse/ActiveRecord
ActiveRecord::Associations::Preloader.new.preload(preloadable_statuses(statuses), :tags)
# rubocop: enable CodeReuse/ActiveRecord
end
end
private
def preloadable_statuses(statuses)
statuses.reject do |status|
status.instance_of?(::GenericCommitStatus) || status.instance_of?(::Ci::Bridge)
end
end
end
end
- statuses = stage.present(current_user: current_user).preloaded_statuses
%tr %tr
%th{ colspan: 10 } %th{ colspan: 10 }
%strong %strong
...@@ -6,8 +8,8 @@ ...@@ -6,8 +8,8 @@
= ci_icon_for_status(stage.status) = ci_icon_for_status(stage.status)
&nbsp; &nbsp;
= stage.name.titleize = stage.name.titleize
= render stage.statuses.latest_ordered, stage: false, ref: false, pipeline_link: false, allow_retry: true = render statuses.latest_ordered, stage: false, ref: false, pipeline_link: false, allow_retry: true
= render stage.statuses.retried_ordered, stage: false, ref: false, pipeline_link: false, retried: true = render statuses.retried_ordered, stage: false, ref: false, pipeline_link: 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