Class: Gitlab::Analytics::CycleAnalytics::StageEvents::CodeStageStart

Inherits:
StageEvent
  • Object
show all
Defined in:
lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StageEvent

#apply_negated_query_customization, #hash_code, #html_description, #initialize, label_based?, #timestamp_projection

Methods included from Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from CycleAnalytics::MetricsTables

#build_table, #issue_metrics_table, #issue_table, #mr_closing_issues_table, #mr_diff_commits_table, #mr_diff_table, #mr_metrics_table, #mr_table, #projects_table, #routes_table, #user_table

Constructor Details

This class inherits a constructor from Gitlab::Analytics::CycleAnalytics::StageEvents::StageEvent

Class Method Details

.identifierObject


12
13
14
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 12

def self.identifier
  :code_stage_start
end

.nameObject


8
9
10
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 8

def self.name
  s_("CycleAnalyticsEvent|Issue first mentioned in a commit")
end

Instance Method Details

#apply_query_customization(query) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


28
29
30
31
32
33
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 28

def apply_query_customization(query)
  query
    .joins(merge_requests_closing_issues_join)
    .joins(issue_metrics_join)
    .joins(mr_metrics_join)
end

#column_listObject


20
21
22
23
24
25
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 20

def column_list
  [
    issue_metrics_table[:first_mentioned_in_commit_at],
    mr_metrics_table[:first_commit_at]
  ]
end

#include_in(query) ⇒ Object


57
58
59
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 57

def include_in(query)
  query.left_joins(merge_requests_closing_issues: { issue: [:metrics] }, metrics: [])
end

#issue_metrics_joinObject

rubocop: enable CodeReuse/ActiveRecord


36
37
38
39
40
41
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 36

def issue_metrics_join
  mr_closing_issues_table
    .join(issue_metrics_table, Arel::Nodes::OuterJoin)
    .on(mr_closing_issues_table[:issue_id].eq(issue_metrics_table[:issue_id]))
    .join_sources
end

#merge_requests_closing_issues_joinObject


43
44
45
46
47
48
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 43

def merge_requests_closing_issues_join
  mr_table
    .join(mr_closing_issues_table, Arel::Nodes::OuterJoin)
    .on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id]))
    .join_sources
end

#mr_metrics_joinObject


50
51
52
53
54
55
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 50

def mr_metrics_join
  mr_metrics_table
    .join(mr_metrics_table, Arel::Nodes::OuterJoin)
    .on(mr_metrics_table[:merge_request_id].eq(mr_table[:id]))
    .join_sources
end

#object_typeObject


16
17
18
# File 'lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb', line 16

def object_type
  MergeRequest
end