Class: Gitlab::Analytics::CycleAnalytics::BaseQueryBuilder

Inherits:
Object
  • Object
show all
Includes:
CycleAnalytics::MetricsTables
Defined in:
lib/gitlab/analytics/cycle_analytics/base_query_builder.rb

Constant Summary collapse

FINDER_CLASSES =
{
  MergeRequest.to_s => MergeRequestsFinder,
  Issue.to_s => IssuesFinder
}.freeze

Instance Method Summary collapse

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

#initialize(stage:, params: {}) ⇒ BaseQueryBuilder

Returns a new instance of BaseQueryBuilder.


16
17
18
19
# File 'lib/gitlab/analytics/cycle_analytics/base_query_builder.rb', line 16

def initialize(stage:, params: {})
  @stage = stage
  @params = build_finder_params(params)
end

Instance Method Details

#buildObject

rubocop: disable CodeReuse/ActiveRecord


22
23
24
25
26
27
# File 'lib/gitlab/analytics/cycle_analytics/base_query_builder.rb', line 22

def build
  query = finder.execute
  query = stage.start_event.apply_query_customization(query)
  query = stage.end_event.apply_query_customization(query)
  query.where(duration_condition)
end