summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/summary/group/deploy.rb
blob: 78d677cf5585e03be3732a0010ddfa542a2a5f72 (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
25
26
27
28
29
30
# frozen_string_literal: true

module Gitlab
  module CycleAnalytics
    module Summary
      module Group
        class Deploy < Group::Base
          include GroupProjectsProvider

          def title
            n_('Deploy', 'Deploys', value)
          end

          def value
            @value ||= find_deployments
          end

          private

          def find_deployments
            deployments = Deployment.joins(:project).merge(Project.inside_path(group.full_path))
            deployments = deployments.where(projects: { id: options[:projects] }) if options[:projects]
            deployments = deployments.where("deployments.created_at > ?", from)
            deployments.success.count
          end
        end
      end
    end
  end
end