Welcome to mirror list, hosted at ThFree Co, Russian Federation.

daily_build_group_report_result_serializer.rb « ci « serializers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fdc693d01b2dd1166547d0b1b30d6c778d4a9704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Ci
  class DailyBuildGroupReportResultSerializer < BaseSerializer
    entity ::Ci::DailyBuildGroupReportResultEntity

    def represent(resource, opts = {})
      group(resource).map do |group_name, data|
        {
          group_name: group_name,
          data: super(data, opts)
        }
      end
    end

    private

    def group(resource)
      collect(resource).group_by(&:group_name)
    end

    def collect(resource)
      return resource if resource.respond_to?(:group_by)

      [resource]
    end
  end
end