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

base.rb « cycle_analytics « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 240be10c1f91498ec67d1fdb02f39e147483e6ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module CycleAnalytics
  class Base
    STAGES = %i[issue plan code test review staging production].freeze

    def all_medians_per_stage
      STAGES.each_with_object({}) do |stage_name, medians_per_stage|
        medians_per_stage[stage_name] = self[stage_name].median
      end
    end

    def stats
      @stats ||= stats_per_stage
    end

    def no_stats?
      stats.all? { |hash| hash[:value].nil? }
    end

    def [](stage_name)
      Gitlab::CycleAnalytics::Stage[stage_name].new(project: @project, options: @options)
    end

    private

    def stats_per_stage
      STAGES.map do |stage_name|
        self[stage_name].as_json
      end
    end
  end
end