Class: Gitlab::Analytics::CycleAnalytics::Median
- Inherits:
-
Object
- Object
- Gitlab::Analytics::CycleAnalytics::Median
- Includes:
- StageQueryHelpers
- Defined in:
- lib/gitlab/analytics/cycle_analytics/median.rb
Instance Method Summary collapse
-
#days ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
-
#initialize(stage:, query:, params: {}) ⇒ Median
constructor
A new instance of Median.
-
#seconds ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
Methods included from StageQueryHelpers
#duration, #end_event_timestamp_projection, #execute_query, #in_progress?, #order_by, #requires_grouping?, #round_duration_to_seconds, #zero_interval
Constructor Details
#initialize(stage:, query:, params: {}) ⇒ Median
Returns a new instance of Median.
9 10 11 12 13 |
# File 'lib/gitlab/analytics/cycle_analytics/median.rb', line 9 def initialize(stage:, query:, params: {}) @stage = stage @query = query @params = params end |
Instance Method Details
#days ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
24 25 26 |
# File 'lib/gitlab/analytics/cycle_analytics/median.rb', line 24 def days seconds ? seconds.fdiv(1.day) : nil end |
#seconds ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
16 17 18 19 20 21 |
# File 'lib/gitlab/analytics/cycle_analytics/median.rb', line 16 def seconds @query = @query.select(median_duration_in_seconds.as('median')).reorder(nil) result = execute_query(@query).first || {} result['median'] || nil end |