diff options
Diffstat (limited to 'app/serializers/stage_entity.rb')
-rw-r--r-- | app/serializers/stage_entity.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/serializers/stage_entity.rb b/app/serializers/stage_entity.rb index 548ff577863..f278ccfce73 100644 --- a/app/serializers/stage_entity.rb +++ b/app/serializers/stage_entity.rb @@ -50,14 +50,6 @@ class StageEntity < Grape::Entity stage.detailed_status(request.current_user) end - def grouped_statuses - @grouped_statuses ||= stage.statuses.latest_ordered.group_by(&:status) - end - - def grouped_retried_statuses - @grouped_retried_statuses ||= stage.statuses.retried_ordered.group_by(&:status) - end - def latest_statuses Ci::HasStatus::ORDERED_STATUSES.flat_map do |ordered_status| grouped_statuses.fetch(ordered_status, []) @@ -69,4 +61,18 @@ class StageEntity < Grape::Entity grouped_retried_statuses.fetch(ordered_status, []) end end + + def grouped_statuses + @grouped_statuses ||= preload_metadata(stage.statuses.latest_ordered).group_by(&:status) + end + + def grouped_retried_statuses + @grouped_retried_statuses ||= preload_metadata(stage.statuses.retried_ordered).group_by(&:status) + end + + def preload_metadata(statuses) + Preloaders::CommitStatusPreloader.new(statuses).execute([:metadata]) + + statuses + end end |