diff options
author | James Lopez <james@jameslopez.es> | 2016-11-17 13:22:27 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-17 13:22:27 +0100 |
commit | ed39d61d746925e49d952bd8169499d3200ae68b (patch) | |
tree | 33128144980f4b62e96309e9ed4c23133422159b /app/models/cycle_analytics.rb | |
parent | f9de157e70234748cf4285fafda7b3ec13862f5c (diff) | |
download | gitlab-ce-ed39d61d746925e49d952bd8169499d3200ae68b.tar.gz |
refactor events facade so it uses separate classes and refactor query stuff
Diffstat (limited to 'app/models/cycle_analytics.rb')
-rw-r--r-- | app/models/cycle_analytics.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb index 30ca3273a2c..314a1ce9b63 100644 --- a/app/models/cycle_analytics.rb +++ b/app/models/cycle_analytics.rb @@ -1,9 +1,8 @@ class CycleAnalytics - include Gitlab::CycleAnalytics::MetricsFetcher - def initialize(project, from:) @project = project @from = from + @fetcher = Gitlab::CycleAnalytics::MetricsFetcher.new(project: project, from: from, branch: nil) end def summary @@ -11,45 +10,45 @@ class CycleAnalytics end def issue - calculate_metric(: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]]) end def plan - calculate_metric(: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 - calculate_metric(:code, + @fetcher.calculate_metric(:code, Issue::Metrics.arel_table[:first_mentioned_in_commit_at], MergeRequest.arel_table[:created_at]) end def test - calculate_metric(:test, + @fetcher.calculate_metric(:test, MergeRequest::Metrics.arel_table[:latest_build_started_at], MergeRequest::Metrics.arel_table[:latest_build_finished_at]) end def review - calculate_metric(:review, + @fetcher.calculate_metric(:review, MergeRequest.arel_table[:created_at], MergeRequest::Metrics.arel_table[:merged_at]) end def staging - calculate_metric(:staging, + @fetcher.calculate_metric(:staging, MergeRequest::Metrics.arel_table[:merged_at], MergeRequest::Metrics.arel_table[:first_deployed_to_production_at]) end def production - calculate_metric(:production, + @fetcher.calculate_metric(:production, Issue.arel_table[:created_at], MergeRequest::Metrics.arel_table[:first_deployed_to_production_at]) end |