summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-18 16:38:02 +0100
committerJames Lopez <james@jameslopez.es>2017-01-17 11:32:54 +0100
commit3268e3779166c7ddf47ecc0d78397cd75cf2f0e8 (patch)
tree44f40dfcdad45c14d154d4019a13d5ccf17f22de /app/models
parente7fdb1aae5a61b30f66ea3489d4e0759ed8ea3a1 (diff)
downloadgitlab-ce-3268e3779166c7ddf47ecc0d78397cd75cf2f0e8.tar.gz
WIP - started refactoring cycle analytics median stuff into stages
Diffstat (limited to 'app/models')
-rw-r--r--app/models/cycle_analytics.rb47
1 files changed, 7 insertions, 40 deletions
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb
index ba4ee6fcf9d..5e33273c9ba 100644
--- a/app/models/cycle_analytics.rb
+++ b/app/models/cycle_analytics.rb
@@ -1,17 +1,17 @@
class CycleAnalytics
STAGES = %i[issue plan code test review staging production].freeze
- def initialize(project, current_user, from:)
+ def initialize(project, from:)
@project = project
- @current_user = current_user
- @from = from
- @fetcher = Gitlab::CycleAnalytics::MetricsFetcher.new(project: project, from: from, branch: nil)
+ @options = options
end
def summary
- @summary ||= Summary.new(@project, @current_user, from: @from)
+ @summary ||= Summary.new(@project, from: @options[:from])
end
+ def method_missing(method_sym, *arguments, &block)
+ classify_stage(method_sym).new(project: @project, options: @options, stage: method_sym)
def permissions(user:)
Gitlab::CycleAnalytics::Permissions.get(user: user, project: @project)
end
@@ -23,40 +23,7 @@ class CycleAnalytics
Issue::Metrics.arel_table[:first_added_to_board_at]])
end
- def plan
- @fetcher.calculate_metric(:plan,
- [Issue::Metrics.arel_table[:first_associated_with_milestone_at],
- Issue::Metrics.arel_table[:first_added_to_board_at]],
- Issue::Metrics.arel_table[:first_mentioned_in_commit_at])
- end
-
- def code
- @fetcher.calculate_metric(:code,
- Issue::Metrics.arel_table[:first_mentioned_in_commit_at],
- MergeRequest.arel_table[:created_at])
- end
-
- def test
- @fetcher.calculate_metric(:test,
- MergeRequest::Metrics.arel_table[:latest_build_started_at],
- MergeRequest::Metrics.arel_table[:latest_build_finished_at])
- end
-
- def review
- @fetcher.calculate_metric(:review,
- MergeRequest.arel_table[:created_at],
- MergeRequest::Metrics.arel_table[:merged_at])
- end
-
- def staging
- @fetcher.calculate_metric(:staging,
- MergeRequest::Metrics.arel_table[:merged_at],
- MergeRequest::Metrics.arel_table[:first_deployed_to_production_at])
- end
-
- def production
- @fetcher.calculate_metric(:production,
- Issue.arel_table[:created_at],
- MergeRequest::Metrics.arel_table[:first_deployed_to_production_at])
+ def classify_stage(method_sym)
+ "Gitlab::CycleAnalytics::#{method_sym.to_s.capitalize}Stage".constantize
end
end