summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/stage_summary.rb
blob: ea440c441b7e932a2e3799c4343c1a4ed619d941 (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
# frozen_string_literal: true

module Gitlab
  module CycleAnalytics
    class StageSummary
      def initialize(project, from:, to: nil, current_user:)
        @project = project
        @from = from
        @to = to
        @current_user = current_user
      end

      def data
        [serialize(Summary::Issue.new(project: @project, from: @from, to: @to, current_user: @current_user)),
         serialize(Summary::Commit.new(project: @project, from: @from, to: @to)),
         serialize(Summary::Deploy.new(project: @project, from: @from, to: @to))]
      end

      private

      def serialize(summary_object)
        AnalyticsSummarySerializer.new.represent(summary_object)
      end
    end
  end
end