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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-22 16:29:25 +0300
committerJames Lopez <james@jameslopez.es>2017-01-17 13:32:54 +0300
commit02e1e4819234662faddd7d8eb5c54d9bfdf9e7e6 (patch)
treed789f920c5d3dd66f140c9dcfe774ac158623ca4 /app/models/cycle_analytics.rb
parent8639ea1b0315045c0e4a5ad8d6419903507850c3 (diff)
more refactoring and fixing old specs
Diffstat (limited to 'app/models/cycle_analytics.rb')
-rw-r--r--app/models/cycle_analytics.rb26
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