diff options
author | James Lopez <james@jameslopez.es> | 2016-11-22 14:29:25 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-01-17 11:32:54 +0100 |
commit | 02e1e4819234662faddd7d8eb5c54d9bfdf9e7e6 (patch) | |
tree | d789f920c5d3dd66f140c9dcfe774ac158623ca4 /app/models/cycle_analytics.rb | |
parent | 8639ea1b0315045c0e4a5ad8d6419903507850c3 (diff) | |
download | gitlab-ce-02e1e4819234662faddd7d8eb5c54d9bfdf9e7e6.tar.gz |
more refactoring and fixing old specs
Diffstat (limited to 'app/models/cycle_analytics.rb')
-rw-r--r-- | app/models/cycle_analytics.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb index 9681d34f2d1..00e9f7c7d5c 100644 --- a/app/models/cycle_analytics.rb +++ b/app/models/cycle_analytics.rb @@ -1,7 +1,7 @@ class CycleAnalytics STAGES = %i[issue plan code test review staging production].freeze - def initialize(project, from:) + def initialize(project, options:) @project = project @options = options end @@ -10,22 +10,28 @@ class CycleAnalytics @summary ||= Gitlab::CycleAnalytics::Summary.new(@project, from: @options[:from]).data end - def method_missing(method_sym, *arguments, &block) - classify_stage(method_sym).new(project: @project, options: @options, stage: method_sym) + def stats + @stats ||= stats_per_stage + end + + def no_stats? + stats.map(&:value).compact.empty? end def permissions(user:) Gitlab::CycleAnalytics::Permissions.get(user: user, project: @project) end - def issue - @fetcher.calculate_metric(:issue, - Issue.arel_table[:created_at], - [Issue::Metrics.arel_table[:first_associated_with_milestone_at], - Issue::Metrics.arel_table[:first_added_to_board_at]]) + private + + def stats_per_stage + STAGES.map do |stage_name| + classify_stage(method_sym).new(project: @project, options: @options, stage: stage_name).median_data + end end - def classify_stage(method_sym) - "Gitlab::CycleAnalytics::#{method_sym.to_s.capitalize}Stage".constantize + def classify_stage(stage_name) + "Gitlab::CycleAnalytics::#{stage_name.to_s.capitalize}Stage".constantize end + end |