summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/production_event.rb
blob: 80c0d08c0395444ec99f5cd7447e85a1101b649c (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
29
30
module Gitlab
  module CycleAnalytics
    class ProductionEvent < BaseEvent
      def initialize(*args)
        @stage = :production
        @start_time_attrs = issue_table[:created_at]
        @end_time_attrs = mr_metrics_table[:first_deployed_to_production_at]
        @projections = [issue_table[:title],
                        issue_table[:iid],
                        issue_table[:id],
                        issue_table[:created_at],
                        issue_table[:author_id]]

        super(*args)
      end

      private

      def serialize(event)
        event['author'] = User.find(event.delete('author_id'))

        AnalyticsIssueSerializer.new(project: @project).represent(event).as_json
      end

      def has_permission?(id)
        @options[:current_user].can?(:read_issue, Issue.find(id))
      end
    end
  end
end