summaryrefslogtreecommitdiff
path: root/app/models/cycle_analytics/summary.rb
blob: 53b2cacb131f9e8fbdfc2d008892c309e1dcc4c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class CycleAnalytics
  class Summary
    def initialize(project, from:)
      @project = project
      @from = from
    end

    def new_issues
      @project.issues.created_after(@from).count
    end

    def commits
      repository = @project.repository.raw_repository

      if @project.default_branch
        repository.log(ref: @project.default_branch, after: @from).count
      end
    end

    def deploys
      @project.deployments.where("created_at > ?", @from).count
    end
  end
end