summaryrefslogtreecommitdiff
path: root/app/presenters
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-06 00:07:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-06 00:07:48 +0000
commit2349eabc1a473bfb70555f0ce6d3d808cecb181d (patch)
tree0dae6a2a6810f2198eed42b7f9566ebf9c292468 /app/presenters
parent134fe182008dc13a16f12d723aa73771efb1a6a2 (diff)
downloadgitlab-ce-2349eabc1a473bfb70555f0ce6d3d808cecb181d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/ci/legacy_stage_presenter.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/presenters/ci/legacy_stage_presenter.rb b/app/presenters/ci/legacy_stage_presenter.rb
new file mode 100644
index 00000000000..2a60b1280da
--- /dev/null
+++ b/app/presenters/ci/legacy_stage_presenter.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Ci
+ class LegacyStagePresenter < Gitlab::View::Presenter::Delegated
+ presents :legacy_stage
+
+ def latest_ordered_statuses
+ preload_statuses(legacy_stage.statuses.latest_ordered)
+ end
+
+ def retried_ordered_statuses
+ preload_statuses(legacy_stage.statuses.retried_ordered)
+ end
+
+ private
+
+ def preload_statuses(statuses)
+ statuses.tap do |statuses|
+ # rubocop: disable CodeReuse/ActiveRecord
+ ActiveRecord::Associations::Preloader.new.preload(preloadable_statuses(statuses), :tags)
+ # rubocop: enable CodeReuse/ActiveRecord
+ end
+ end
+
+ def preloadable_statuses(statuses)
+ statuses.reject do |status|
+ status.instance_of?(::GenericCommitStatus) || status.instance_of?(::Ci::Bridge)
+ end
+ end
+ end
+end