debian-mirror-gitlab/lib/gitlab/analytics/cycle_analytics/aggregated/median.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
822 B
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
module Gitlab
module Analytics
module CycleAnalytics
module Aggregated
class Median
include StageQueryHelpers
def initialize(stage:, query:, params:)
@stage = stage
@query = query
@params = params
end
# rubocop: disable CodeReuse/ActiveRecord
def seconds
2022-01-26 12:08:38 +05:30
@query = @query.select(duration_in_seconds(percentile_cont).as('median')).reorder(nil)
2021-12-11 22:18:48 +05:30
result = @query.take || {}
result['median'] || nil
end
# rubocop: enable CodeReuse/ActiveRecord
def days
seconds ? seconds.fdiv(1.day) : nil
end
private
attr_reader :stage, :query, :params
end
end
end
end
end