summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/summary/group/issue.rb
blob: 6d9a31ad43e96e1b3760bb7b3a656f8560813d00 (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
31
32
33
34
# frozen_string_literal: true

module Gitlab
  module CycleAnalytics
    module Summary
      module Group
        class Issue < Group::Base
          def initialize(group:, from:, current_user:, options:)
            @group = group
            @from = from
            @current_user = current_user
            @options = options
          end

          def title
            n_('New Issue', 'New Issues', value)
          end

          def value
            @value ||= find_issues
          end

          private

          def find_issues
            issues = IssuesFinder.new(@current_user, group_id: @group.id, include_subgroups: true).execute
            issues = issues.where(projects: { id: @options[:projects] }) if @options[:projects]
            issues.created_after(@from).count
          end
        end
      end
    end
  end
end