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

Inherits:
Object
  • Object
show all
Includes:
StageQueryHelpers, 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
DEFAULT_END_EVENT_FILTER =
:finished

Instance Method Summary collapse

Methods included from StageQueryHelpers

#duration, #end_event_timestamp_projection, #execute_query, #in_progress?, #order_by, #requires_grouping?, #round_duration_to_seconds, #zero_interval

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.


19
20
21
22
23
# File 'lib/gitlab/analytics/cycle_analytics/base_query_builder.rb', line 19

def initialize(stage:, params: {})
  @stage = stage
  @params = build_finder_params(params)
  @params[:state] = :opened if in_progress?
end

Instance Method Details

#buildObject

rubocop: disable CodeReuse/ActiveRecord


26
27
28
29
30
# File 'lib/gitlab/analytics/cycle_analytics/base_query_builder.rb', line 26

def build
  query = finder.execute
  query = stage.start_event.apply_query_customization(query)
  apply_end_event_query_customization(query)
end