summaryrefslogtreecommitdiff
path: root/lib/gitlab/analytics/cycle_analytics/stage_events/issue_deployed_to_production.rb
blob: 3e93e60e686a896359c3b6c8e9740cabf84e3d11 (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
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Gitlab
  module Analytics
    module CycleAnalytics
      module StageEvents
        class IssueDeployedToProduction < StageEvent
          def self.name
            _("Issue first deployed to production")
          end

          def self.identifier
            :issue_deployed_to_production
          end

          def object_type
            Issue
          end

          def timestamp_projection
            mr_metrics_table[:first_deployed_to_production_at]
          end

          override :column_list
          def column_list
            [timestamp_projection]
          end

          # rubocop: disable CodeReuse/ActiveRecord
          def apply_query_customization(query)
            query.joins(merge_requests_closing_issues: { merge_request: [:metrics] }).where(mr_metrics_table[:first_deployed_to_production_at].gteq(mr_table[:created_at]))
          end
          # rubocop: enable CodeReuse/ActiveRecord
        end
      end
    end
  end
end