2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module CycleAnalytics
|
|
|
|
module SummaryHelper
|
|
|
|
def frequency(count, from, to)
|
2020-10-24 23:57:45 +05:30
|
|
|
return Summary::Value::None.new if count == 0
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
freq = (count / days(from, to)).round(1)
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
Summary::Value::Numeric.new(freq)
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def days(from, to)
|
|
|
|
[(to.end_of_day - from.beginning_of_day).fdiv(1.day), 1].max
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|