summaryrefslogtreecommitdiff
path: root/app/models/cycle_analytics
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-22 11:46:02 +0100
committerJames Lopez <james@jameslopez.es>2017-01-17 11:32:54 +0100
commitfc6f8f20562ad761c034ffff076d329a3e9e8f4d (patch)
tree401c48a79209f656fa74dffe102d4385caefea76 /app/models/cycle_analytics
parentdc6ea14b0d11a5e73e81c95ef723f0c1af69215b (diff)
downloadgitlab-ce-fc6f8f20562ad761c034ffff076d329a3e9e8f4d.tar.gz
added new summary serializers and refactor all of the summary stuff into separate logical classes
Diffstat (limited to 'app/models/cycle_analytics')
-rw-r--r--app/models/cycle_analytics/summary.rb43
1 files changed, 0 insertions, 43 deletions
diff --git a/app/models/cycle_analytics/summary.rb b/app/models/cycle_analytics/summary.rb
index c9910d8cd09..e69de29bb2d 100644
--- a/app/models/cycle_analytics/summary.rb
+++ b/app/models/cycle_analytics/summary.rb
@@ -1,43 +0,0 @@
-class CycleAnalytics
- class Summary
- def initialize(project, current_user, from:)
- @project = project
- @current_user = current_user
- @from = from
- end
-
- def new_issues
- IssuesFinder.new(@current_user, project_id: @project.id).execute.created_after(@from).count
- end
-
- def commits
- ref = @project.default_branch.presence
- count_commits_for(ref)
- end
-
- def deploys
- @project.deployments.where("created_at > ?", @from).count
- end
-
- private
-
- # Don't use the `Gitlab::Git::Repository#log` method, because it enforces
- # a limit. Since we need a commit count, we _can't_ enforce a limit, so
- # the easiest way forward is to replicate the relevant portions of the
- # `log` function here.
- def count_commits_for(ref)
- return unless ref
-
- repository = @project.repository.raw_repository
- sha = @project.repository.commit(ref).sha
-
- cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{repository.path} log)
- cmd << '--format=%H'
- cmd << "--after=#{@from.iso8601}"
- cmd << sha
-
- raw_output = IO.popen(cmd) { |io| io.read }
- raw_output.lines.count
- end
- end
-end