Class: Gitlab::AlertManagement::AlertStatusCounts

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/alert_management/alert_status_counts.rb

Overview

Represents counts of each status or category of statuses

Constant Summary collapse

STATUSES =
::AlertManagement::Alert::STATUSES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(current_user, project, params) ⇒ AlertStatusCounts

Returns a new instance of AlertStatusCounts.


17
18
19
20
21
# File 'lib/gitlab/alert_management/alert_status_counts.rb', line 17

def initialize(current_user, project, params)
  @project = project
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project


11
12
13
# File 'lib/gitlab/alert_management/alert_status_counts.rb', line 11

def project
  @project
end

Class Method Details

.declarative_policy_classObject


13
14
15
# File 'lib/gitlab/alert_management/alert_status_counts.rb', line 13

def self.declarative_policy_class
  'AlertManagement::AlertPolicy'
end

Instance Method Details

#allObject


32
33
34
# File 'lib/gitlab/alert_management/alert_status_counts.rb', line 32

def all
  counts.values.sum # rubocop:disable CodeReuse/ActiveRecord
end

#openObject


28
29
30
# File 'lib/gitlab/alert_management/alert_status_counts.rb', line 28

def open
  counts[:triggered] + counts[:acknowledged]
end