2020-04-15 14:09:36 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module CycleAnalytics
|
|
|
|
module SummaryHelper
|
|
|
|
def frequency(count, from, to)
|
2020-04-21 11:21:10 -04:00
|
|
|
return count if count.zero?
|
|
|
|
|
|
|
|
freq = (count / days(from, to)).round(1)
|
|
|
|
freq.zero? ? '0' : freq
|
2020-04-15 14:09:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def days(from, to)
|
2020-04-21 11:21:10 -04:00
|
|
|
[(to.end_of_day - from.beginning_of_day).fdiv(1.day), 1].max
|
2020-04-15 14:09:36 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|