summaryrefslogtreecommitdiff
path: root/app/serializers/ci/dag_pipeline_entity.rb
blob: 51aa487ec2909c7eba79a455c0c56659563d7e49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module Ci
  class DagPipelineEntity < Grape::Entity
    expose :stages_with_preloads, as: :stages, using: Ci::DagStageEntity

    private

    def stages_with_preloads
      object.stages.preload(preloaded_relations) # rubocop: disable CodeReuse/ActiveRecord
    end

    def preloaded_relations
      [
        :project,
        { latest_statuses: :needs }
      ]
    end
  end
end