Welcome to mirror list, hosted at ThFree Co, Russian Federation.

summary_helper.rb « cycle_analytics « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 11e48679a404190a1641fbc3427910f4a5b436bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Gitlab
  module CycleAnalytics
    module SummaryHelper
      def frequency(count, from, to)
        return Summary::Value::None.new if count == 0

        freq = (count / days(from, to)).round(1)

        Summary::Value::Numeric.new(freq)
      end

      def days(from, to)
        [(to.end_of_day - from.beginning_of_day).fdiv(1.day), 1].max
      end
    end
  end
end