Class: Gitlab::Analytics::CycleAnalytics::Aggregated::Median
- Inherits:
-
Object
- Object
- Gitlab::Analytics::CycleAnalytics::Aggregated::Median
- Includes:
- StageQueryHelpers
- Defined in:
- lib/gitlab/analytics/cycle_analytics/aggregated/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, #duration_in_seconds, #in_progress?, #percentile_cont
Constructor Details
#initialize(stage:, query:, params:) ⇒ Median
Returns a new instance of Median.
10 11 12 13 14 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/median.rb', line 10 def initialize(stage:, query:, params:) @stage = stage @query = query @params = params end |
Instance Method Details
#days ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
25 26 27 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/median.rb', line 25 def days seconds ? seconds.fdiv(1.day) : nil end |
#seconds ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
17 18 19 20 21 22 |
# File 'lib/gitlab/analytics/cycle_analytics/aggregated/median.rb', line 17 def seconds @query = @query.select(duration_in_seconds(percentile_cont).as('median')).reorder(nil) result = @query.take || {} result['median'] || nil end |