Module: Gitlab::Analytics::CycleAnalytics::Aggregated::StageQueryHelpers
- Included in:
- BaseQueryBuilder, Median
- Defined in:
- lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb
Instance Method Summary collapse
- #duration ⇒ Object
- #duration_in_seconds(duration_expression = duration) ⇒ Object
- #in_progress? ⇒ Boolean
- #percentile_cont ⇒ Object
Instance Method Details
#duration ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb', line 16 def duration if in_progress? Arel::Nodes::Subtraction.new( Arel::Nodes::NamedFunction.new('TO_TIMESTAMP', [Time.current.to_i]), query.model.arel_table[:start_event_timestamp] ) else Arel::Nodes::Subtraction.new( query.model.arel_table[:end_event_timestamp], query.model.arel_table[:start_event_timestamp] ) end end |
#duration_in_seconds(duration_expression = duration) ⇒ Object
34 35 36 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb', line 34 def duration_in_seconds(duration_expression = duration) Arel::Nodes::NamedFunction.new('CAST', [Arel::Nodes::Extract.new(duration_expression, :epoch).as('double precision')]) end |
#in_progress? ⇒ Boolean
30 31 32 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb', line 30 def in_progress? params[:end_event_filter] == :in_progress end |
#percentile_cont ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb', line 8 def percentile_cont percentile_cont_ordering = Arel::Nodes::UnaryOperation.new(Arel::Nodes::SqlLiteral.new('ORDER BY'), duration) Arel::Nodes::NamedFunction.new( 'percentile_cont(0.5) WITHIN GROUP', [percentile_cont_ordering] ) end |